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
1 On 15-06-2012 09:35:38 -0400, Ian Stakenvicius wrote:
2 > On 15/06/12 09:27 AM, Peter Stuge wrote:
3 > > Mike Frysinger wrote:
4 > >>> + # lets see if the username already exists + if [[
5 > >>> ! -n $(egetent passwd "${euser}") ]] ; then
6 > >>
7 > >> "! -n" -> "-z"
8 > >
9 > > Does the $() argument ever need to be double quoted, or do all
10 > > versions of bash actually have the string argument optional even
11 > > though that's not what the man page reads?
12 >
13 > Ever? Yes, but only if what is being returned can contain spaces (and
14 > this matters in the way that it's used). In the case of 'egetent
15 > passwd', afaict no as it doesn't return anything with whitespace in it.
16 >
17 > Examples -- this works:
18 >
19 > $ bubba="test thing" ; if [ -n "$(echo $bubba)" ]; then echo OK; fi
20 > OK
21 >
22 > Example -- this fails:
23 >
24 > $ bubba="test thing" ; if [ -n $(echo $bubba) ]; then echo OK; fi
25 > bash: [: test: binary operator expected
26
27 Yes, but this works:
28
29 $ bubba="test thing" ; if [[ -n $(echo $bubba) ]]; then echo OK; fi
30 OK
31
32 (and he's using [[, not [)
33
34 --
35 Fabian Groffen
36 Gentoo on a different level

Attachments

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