[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange Problem with 'test' or '['
From: |
Greg Wooledge |
Subject: |
Re: Strange Problem with 'test' or '[' |
Date: |
Wed, 23 Dec 2015 10:20:42 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Dec 23, 2015 at 04:05:28PM +0100, Bytec GmbH - Helmut Koeberle wrote:
> OK, with '[[' ist's working!
>
> if ([[ "true" = "true" ]] && [[ "${h:0:1}" = "/" ]]); then echo slash; fi
You don't need parentheses around it. The parentheses force the commands
to run in a subshell (fork()), so it just slows things down.
> if [[ "true" = "true" ]] && [[ "${h:0:1}" = "/" ]]; then echo slash; fi
This is fine, but also note that you can put && inside [[ if you wish:
[[ "true" = "true" && "${h:0:1}" = "/" ]]
Or you can use pattern matching:
[[ "true" = "true" && $h = /* ]]