Gentoo Archives: gentoo-dev

From: Fabian Groffen <grobian@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] RFC: esethome
Date: Fri, 15 Jun 2012 13:41:31
Message-Id: 20120615133926.GD936@gentoo.org
In Reply to: Re: [gentoo-dev] RFC: esethome by Ian Stakenvicius
On 15-06-2012 09:35:38 -0400, Ian Stakenvicius wrote:
> On 15/06/12 09:27 AM, Peter Stuge wrote: > > Mike Frysinger wrote: > >>> + # lets see if the username already exists + if [[ > >>> ! -n $(egetent passwd "${euser}") ]] ; then > >> > >> "! -n" -> "-z" > > > > Does the $() argument ever need to be double quoted, or do all > > versions of bash actually have the string argument optional even > > though that's not what the man page reads? > > Ever? Yes, but only if what is being returned can contain spaces (and > this matters in the way that it's used). In the case of 'egetent > passwd', afaict no as it doesn't return anything with whitespace in it. > > Examples -- this works: > > $ bubba="test thing" ; if [ -n "$(echo $bubba)" ]; then echo OK; fi > OK > > Example -- this fails: > > $ bubba="test thing" ; if [ -n $(echo $bubba) ]; then echo OK; fi > bash: [: test: binary operator expected
Yes, but this works: $ bubba="test thing" ; if [[ -n $(echo $bubba) ]]; then echo OK; fi OK (and he's using [[, not [) -- Fabian Groffen Gentoo on a different level

Attachments

File name MIME type
signature.asc application/pgp-signature