Some bash help needed

Michal Jaegermann michal at harddata.com
Sat Jan 12 18:21:03 UTC 2013


On Sat, Jan 12, 2013 at 11:26:23AM -0500, Gene Czarcinski wrote:
> 
> And here is the patch:
...
> -  abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
> +  abstraction="`"${grub_probe}" --device ${device} --target=abstraction`"
...
> with
> device="/dev/vda2
> /dev/vdb2
> /dev/vdc3"
> 
> Can someone more knowledgeable explain?

Dropping those quotes around ${device} replaces one parameter, which has
spaces inside and so it is not likely be a valid device name, with three
separate ones.  Does not make any difference with a single device but
means something else with multiple ones.  If you would like to visualise
what is going on here try to run the following script:

device="/dev/vda2
/dev/vdb2
/dev/vdc3"

show_args () {
    echo $#
    while [ "$1" ] ; do
	echo $1; shift
    done
}
grub_probe=show_args
abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
echo "$abstraction"

and similar with other variants for 'abstraction'.

I have no idea if

    ... --device /dev/vda2 /dev/vdb2 /dev/vdc3 ...

is indeed a valid syntax for the real ${grub_probe}.  Possibly.

AFAICT "outside double quotes" for 'abstraction', i.e. "`...`" are not
doing here anything useful beyond making this more confusing and harder
to understand. abstraction=`...` would be just fine.

   Michal





More information about the test mailing list