[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange Problem with 'test' or '['
From: |
Chet Ramey |
Subject: |
Re: Strange Problem with 'test' or '[' |
Date: |
Wed, 23 Dec 2015 09:10:46 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
On 12/23/15 5:26 AM, Bytec GmbH - Helmut Koeberle wrote:
> Hello list,
>
> i have a strange problem in bash with the test command.
>
> Here is my simple bash script 'tst' that checks wether the first char of
> an argument is a slash.
> If the first char of the argument is a special char like '(' then it
> works if there is one expression,
> but not with multiple expressions.
This has to do with the Posix rules for `test'. The behavior is strictly
defined for cases where the number of arguments is 0-4 (and these cases are
documented in the description of `test' in the bash documentation). For
five or more arguments, the expression is parsed according to precedence,
and `(' introduces a parenthesized subexpression.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/