On Wed, Dec 17, 2008 at 10:03:09AM -0600, Nicolas Williams wrote:
> To make it easier for you I wrote you the attached function to
> backslash-quote white-space in strings. That way you can change the
> main body of unmountall to:
The attachment didn't make the list, and though you have it, I forgot to
remove debug output. So here it is inlined.
bquote () {
orig=$1
set -- $1
bquoted=$1
shift
while [ $# -gt 0 ]
do
case "$orig" in
$bquoted\ ${1}*) bquoted="$bquoted\\ $1";;
# IF YOU CUT-N-PASTE do make SURE you fix spaces
# back to tabs in the next line!
$bquoted\ ${1}*) bquoted="$bquoted\\ $1";;
*) return 1;;
esac
shift
done
return 0
}
You can test it like so:
while read a b c
do
bquote "$a"
a=$bquoted
bquote "$b"
b=$bquoted
bquote "$c"
c=$bquoted
echo "$a $b $c"
done <<EOF
foo bar baz
foo\\ bar baz
note the tab in the next line
foo\\ bar baz
EOF
Nico
--