Traduisez - Übersetzen - Traduzca - Traduza - Tradurre - Translate

Re: Diagnosing "helper app spawn" errors with Netscape 4

Ted Powell (ted@eslvcr.fireplug.net)
Tue, 24 Mar 1998 00:27:57 -0800

On Mon, Mar 23, 1998 at 05:41:01PM -0800, G. Crimp wrote:
> On Mon, Mar 23, 1998 at 09:32:30AM -0800, Jason Baker wrote:
> > [...]
> > sh: -c: line 1: missing closing ')' for arithmetci expression
> > sh: -c: line 1: syntax error near unexpected token ';'
> > sh: -c: line 1: '((/usr/local/bin/rvplayer /tmp/<filename>); rm /tmp/<filename>) &'
>
> I have this same problem myself. I can't remember which news group
> I was in but I have seen some discussion of this on usenews. Apparently the
> problem is a bug in version 2.00 of bash. Misintrprets the parentheses
> somehow. The solution proposed ( and apparently successfully carried out by
> some of the posters) was to use a different version of bash. This problem was
> apparently only present in version 2.00.

This is the first indication I've seen that perhaps bash 2.00 was being
used. Given this hint, I am able to reproduce Jason's problem by
connecting to a host which has bash 2.00 installed:

$ bash -c '((/usr/local/bin/rvplayer /tmp/foo); rm /tmp/foo) &'
bash: -c: line 1: missing closing `)' for arithmetic expression
bash: -c: line 1: syntax error near unexpected token `;'
bash: -c: line 1: `((/usr/local/bin/rvplayer /tmp/foo); rm /tmp/foo) &'
$

2.00 is, I gather, the first version of bash to implement the arithmetic
command, which has been in ksh for some time. ksh dislikes the command
line generated by Netscape too, though the error message is less clear:

$ ksh -c '((/usr/local/bin/rvplayer /tmp/foo); rm /tmp/foo) &'
ksh: syntax error at line 1 : `(' unmatched
$

With either shell, (( is a two-character token, which must be matched by
the two-character token )).

If Netscape didn't use ((, and instead used two left parens separated
by a space, there would be no problem (assuming existence of the program
and the data file, of course):

$ bash -c '( (/usr/local/bin/rvplayer /tmp/foo); rm /tmp/foo) &'
bash: /usr/local/bin/rvplayer: No such file or directory
$ /tmp/foo: No such file or directory

If I'm not mistaken, the arithmetic command is part of Posix 1003.2, so
it's not likely to go away. Here are a couple of examples of its use:

bash-2.00$ (( 2 + 2 ))
bash-2.00$ echo $?
0
bash-2.00$ (( 2 - 2 ))
bash-2.00$ echo $?
1
bash-2.00$

If the expression inside the (( ... )) evaluates to a non-zero value,
the command returns TRUE (zero result code). If the expression evaluates
to zero, the command returns FALSE (non-zero result code). The expression
can contain shell variables and any of an extensive set of operators.

Earlier versions of bash already had arithmetic expansion, by the way:

$ echo $(( 2 + 2 ))
4

What to do?
- Get the very latest version of Netscape, and see whether the problem
is still there.
- Replace /bin/sh, which is a symlink to /bin/bash, with the binary of
an older version of bash which does not implement the arithmetic
command. (No need to deprive yourself of 2.00 the rest of the time.)
- Replace /bin/sh with a script that checks for a -c option, and
replaces any ((s in the option value with ( (

-- 
ted@psg.com  http://psg.com/~ted/  (Ted Powell)
Promote Responsible Net Commerce: Fight Spam! http://spam.abuse.net/