1 |
Roy Marples <uberlord@g.o> wrote: |
2 |
> On Tuesday 07 November 2006 15:59, Aron Griffis wrote: |
3 |
> > > +if [[ $'\n'$(get_mounts) =~ $'\n'${svcdir}\ && -w ${svclib} ]] ; then |
4 |
> > |
5 |
> > Shouldn't this be: |
6 |
> > |
7 |
> > if [[ $'\n'$(get_mounts) == $'\n'"${svcdir} " ... |
8 |
> > |
9 |
> > because I don't think you want to treat the RHS as either a regex |
10 |
> > (=~) or a glob (unquoted). |
11 |
> |
12 |
> Needs to be regex so I can match $'\n' as iirc you loose that in |
13 |
> globbing |
14 |
|
15 |
I could be missing something, but: |
16 |
|
17 |
[[ $'\nwombat' =~ $'wombat' ]] && \ |
18 |
echo "These compare as equal, with or without the leading \n" |
19 |
|
20 |
They do not compare as equal with the == operator or the = operator. You |
21 |
probably want the = operator, because the == operator _does_ interpret |
22 |
the RHS as a glob. The = operator just uses simple string comparison, |
23 |
without interpreting anything. |
24 |
|
25 |
|
26 |
|
27 |
I am curious about why the space was included at the end of the in the |
28 |
expression: |
29 |
|
30 |
> > > $'\n'${svcdir}\ |
31 |
|
32 |
Does get_mounts add a space to the end of its output? |
33 |
|
34 |
-- |
35 |
Every absurdity has a champion to defend it. |
36 |
-- Oliver Goldsmith |