[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#276722: discover1: "set -e" prevents cdrom mountpoint creation



On Sat, Oct 16, 2004 at 09:11:48AM -0700, Joshua Kwan wrote:
> On Sat, Oct 16, 2004 at 03:23:05PM +0100, Colin Watson wrote:
> > In either case, removing quoting is surely the wrong answer. I'd do one
> > of these:
> > 
> >   mountsent="$(grep " $CDMOUNT " /proc/mounts || true)"
> >   mountsent="$(grep " $CDMOUNT " /proc/mounts)" || true
> 
> I was under the impression that quoting wasn't required for $(...)
> constructs,

Quoting's always good style in shell. As it happens, you get away
without it here because word splitting and pathname expansion are not
performed on the value in a name=value assignment, and those are the
only two expansions that happen after command substitution. All the
same, it promotes better practice to quote everywhere unless there's an
actively good reason not to do so.

> and that having the duplicate double quotes in the middle would render
> void the intentional whitespace.

No, shell quoting rules mean that the initial " doesn't get closed until
the $() is closed. Try it:

  $ foo="$(echo " hello " " world ")"
  $ echo "$foo"
   hello   world

> Are you sure this isn't breaking more than it fixes? :)

I always put double quotes around $(). Besides, you're the one
suggesting a change. :-)

Cheers,

-- 
Colin Watson                                       [cjwatson@debian.org]



Reply to: