[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Netscape: How about some Unix instructions



>>>Warning, Off-topic<<<

Sorry for this arguably off-topic thread, even the original
post was technically off-topic but, it _is_ a Debian bug
(#10598).  The bug was fixed upstream in the June 5 release
of bash-2.01.  I've received private email that pointed out
that the new Debian package is now in Incoming.

Carey Evans wrote:
> 
> Bob Clark <rlclark@usa.net> writes:
> 
> [snip]
> 
> > Bash incorrectly considers (( to be an
> > arithmetic expression introducer when really, it's $((.
> 
> That's strange, since both pdksh and zsh both consider (( to be an
> arithmetic expression, and $(( to be an arithmetic expression
> _substitution_.  Have they both got bugs too?  Only ash doesn't know
> about (( or $((.

You're right about ((, I can't speak for pdksh or zsh sinc I
don't have them installed.  Let me see if I can say what I
can get it right. 

(( does imply an arithmetic expression but if and only if
there'e a matching )).

>From the bash manpage:
---------------[ start manpage snippets ]------------------

       (list) list  is  executed in a subshell.  Variable
assign-
              ments and builtin commands that affect the 
shell's
              environment  do not remain in effect after the
com-
              mand completes.  The return status is the exit
sta-
              tus of list.

       ((expression))
              The expression is evaluated according to the 
rules
              described  below  under  ARITHMETIC
EVALUATION.  If
              the value of the expression is non-zero, the
return
              status  is  0;  otherwise  the  return status
is 1.
              This is exactly equivalent to let
"expression".

  Arithmetic Expansion
       Arithmetic  expansion  allows  the evaluation of an
arith-
       metic expression and the substitution of the
result.   The
       format for arithmetic expansion is:

              $((expression))

       The  expression  is  treated  as  if it were within
double
       quotes, but a double quote inside the parentheses 
is  not
       treated  specially.   All tokens in the expression
undergo
       parameter expansion, string expansion,  command 
substitu-
       tion,  and quote removal.  Arithmetic substitutions
may be
       nested.

       The evaluation is performed according to the rules 
listed
       below  under  ARITHMETIC  EVALUATION.   If 
expression  is
       invalid, bash prints a message indicating failure 
and  no
       substitution occurs.

---------------[ end manpage snippets ]------------------

So, the bug is that bash-2.0 incorrectly considers
((...);...) an arithmetic expression with a missing closing
paren when really it's a proper (list) construct that
_should_ be accepted by the shell.

((...)) is a proper arithmetic expression but ((...) ) is a
nested list.

Similarly, $((...)) is proper form for arithmetic expansion
but $((...) ) is a command substitution that happens to
contain a list since the closing )) is missing.

Bottom line is that bash-2.0 has a bug that makes netscape
helper apps fail; upgarding to bash-2.01 fixes that.

Here's an example of the bug:

$ cd /etc
$ /bin/bash-2.0 -c "((pwd);pwd)"
/bin/bash-2.0: -c: line 1: missing closing `)' for
arithmetic expression
/bin/bash-2.0: -c: line 1: syntax error near unexpected
token `;p'
/bin/bash-2.0: -c: line 1: `((pwd);pwd)'
$
$ /bin/bash-2.1 -c "((pwd);pwd)"
/etc
/etc

What do pdksh and zsh do with this?  Older bash versions (<
2.0) work but 2.0 is broken.

--Bob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: