bug-bash
[Top][All Lists]
Advanced

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

Re: Cannot form valid test expressions that involve brackets as string c


From: Andreas Schwab
Subject: Re: Cannot form valid test expressions that involve brackets as string comparison targets
Date: Thu, 08 Oct 2009 11:16:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Lyall Pearce <address@hidden> writes:

> Repeat-By:
>
>         basePic="(2008-04)"
>     if [ "${basePic:0:1}" = '(' -a "${basePic:4:1}" = ')' ]
>     then
>         echo "Got brackets"
>     fi
      case $basePic in "("???")"*) echo "Got brackets";; esac

> Fix:
>     Unsure, I think the bracket parsing should not be treated as
> expression delimiters if they are enclosed in quotes?

The quotes are irrelevant for the test builtin, they are already eaten
by the parser.

>     If they are bare, then treat as (brackets), if enclosed in quotes,
> treat as "data".

Bare parens would be a syntax error, since they are part of the shell
grammar.

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]