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 |