the zsh -n test is inappropriate. the vux package requires zsh modules, which aren't loaded with -n. monkey % lintian -i ../vux_0.3.4_i386.changes E: vux: shell-script-fails-syntax-check ./usr/bin/vux N: N: Running this shell script with the shell's -n option set fails, which N: means that the script has syntax errors. N: N: Run e.g. sh -n yourscript to see the errors yourself. N: monkey % zsh -n =vux /usr/bin/vux:766: unknown function: int /usr/bin/vux:784: bad math expression: operator expected at `h'
So is zsh -n generally screwed up, or is this a bug in zsh -n?
Well, -n means NO_EXEC, so it would be a bug for zsh -n to execute module load commands. On the other hand, those modules need to be loaded for zsh to know the proper syntax to check. Quite a dilemma. Probably the least ugly thing would be to have a --no-exec --just-kidding-you-can-exec-zmodload-but-nothing-else Who knows if there are other bizarre ramifications.
If you run zsh -n on a script which uses zsh/mathfunc, zsh will not exec zmodload, and thus not be aware of new math syntax. Is an EXEC_ZMODLOAD option in order?
On Jan 5, 3:13pm, Clint Adams wrote:
}
} If you run zsh -n on a script which uses zsh/mathfunc, zsh will
} not exec zmodload, and thus not be aware of new math syntax.
} Is an EXEC_ZMODLOAD option in order?
That solution is not particularly useful. Consider something of the form
if test ...
then zmodload zsh/mathfunc
fi
If you can't execute the conditional because of -n, how do you know that
it's safe to execute the zmodload?
IMO you've identified a deeper problem, which is that no module should be
allowed to alter the syntax accepted by the parser. Conversely, if the
parser is able to cope with the syntax in the absence of the module, then
`zsh -n' has no business complaining about the semantics.
In this example:
`zsh -n' should simply accept that `int' IS a function, and should not try
to look it up.
In this case:
I can't give an opinion, "bad math expression" is too generic an error.
I don't appear to have the same version, but I get the same error on line 788, which is minimum_age=$(( minimum_age * age_format )) Looks like there are some if/thens which are not being executed which would change $minimum_age from "1h" to its equivalent in seconds. Said version attached for your edification.
On Jan 5, 7:19pm, Clint Adams wrote: } } minimum_age=$(( minimum_age * age_format )) } } Looks like there are some if/thens which are not being executed which } would change $minimum_age from "1h" to its equivalent in seconds. OK, so the problem is that `zsh -n' is executing math expressions. It should probably treat math expressions just like any other builtin or command when the -n option is present; that is, do not execute them.
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.36
diff -u -r1.36 subst.c
--- Src/subst.c 30 Aug 2003 19:12:18 -0000 1.36
+++ Src/subst.c 11 Mar 2004 16:20:38 -0000
@@ -168,7 +168,11 @@
if (endchar == Outpar && str2[1] == '(' && str[-2] == ')') {
/* Math substitution of the form $((...)) */
str[-2] = '\0';
- str = arithsubst(str2 + 2, &str3, str);
+ if (isset(EXECOPT)) {
+ str = arithsubst(str2 + 2, &str3, str);
+ } else {
+ strncpy(str3, str2, 1);
+ }
setdata(node, (void *) str3);
continue;
}
Clint Adams wrote: I haven't seen the original, but it probably refers to (( ... )) commands, not $(( ... )) substitutions. But I can't be sure.
[the thread is 18054, 18055, 18056, 18057, 19601, 19620] With respect to the syntax errors caused by zsh/mathfunc not being loaded, it doesn't make sense to substitute $(()) or nor execute (( )) when NO_EXEC is set. I don't know about in general.
found 175467 4.3.9 With vux 0.4.9 and zsh 4.3.9, I get: richih@adamantium 4.3.9-dev-1-cvs1216 ~ % zsh-beta -n =vux /usr/bin/vux:1251: unknown function: int /usr/bin/vux:1269: bad math expression: operator expected at `h' richih@adamantium 4.3.9-dev-1-cvs1216 ~ %