Hello Paul! Paul Vojta wrote in <[email protected]>: |I believe that there's a bug in s-nail, both in Debian version 14.9.11-2
"if -n" does not exist before v14.9.13 (alongside -N which is a better choice, as below). |and in commit 00c264c02c1b411a6d553e610324a34cdbd7e778 on git |(dated 2022-07-07). | |When I run s-nail with the following in my .mailrc file: If you prepend set v15-compat=y | set myvar=a | if -n "$myvar" | echo myvar is set | endif | | echo done | |I get the following output: it will do what you want. | s-nail: if: invalid expression syntax -- near: -n ... |Is this a bug, or if not then what is the correct syntax? I see -n critical, and it must be said our `if' is no good, if you enable v15-compat=y (which will be default in v14.10 somewhen by the end of the year). Because then `if' etc. evaluates its arguments like the shell, and thus if -n "$myvar" where for example "set myvar=[" is a problem the way we do it. Granted test(1) of the sh(1)ell has these problems, too, but there POSIX standardized four special cases to avoid the syntax ambiguities. And a sh(1)ell as such has a notion of language elements, whereas this MUA expands the arguments like the sh(1)ell, and then passes the expansion to the `if' command. We can be fooled thus. In fact i am sitting (beside other problems) on an improvement of this situation on the development branches, but overall it is sheer impossible to avoid any syntax ambiguities (old shell scripts use things like [ x"$foo" = x"$bar" ] to avoid them, but this soon becomes tedious). So my advise for you would be to use -N (or -Z) whenever possible, and/or to say 'if -n x"$myvar"' otherwise. (All with v15-compat set!) Ciao Paul! --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
