Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail From: Greg Wooledge Newsgroups: gnu.bash.bug Subject: Re: Strange Problem with 'test' or '[' Date: Wed, 23 Dec 2015 10:20:42 -0500 Lines: 18 Approved: bug-bash@gnu.org Message-ID: References: <567A76EB.1000506@bytec.de> <20151223140901.GG27325@eeg.ccf.org> <567AB838.5050706@bytec.de> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1450884050 26444 208.118.235.17 (23 Dec 2015 15:20:50 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Bytec GmbH - Helmut Koeberle Envelope-to: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: <567AB838.5050706@bytec.de> User-Agent: Mutt/1.4.2.3i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 139.137.100.1 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:12120 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 = /* ]]