[ale] Undesired shell expansion building a command line
Michael B. Trausch
mbt at zest.trausch.us
Wed Aug 26 15:30:05 EDT 2009
I have the following in a shell script:
EXCLUDED="/dev /sys /proc /tmp /bin /usr/bin /usr/sbin /sbin"
EXCLUDED="${EXCLUDED} /lib /usr/lib *~"
EXCLUDE_ARGS=""
for ARG in $EXCLUDED; do
EXCLUDE_ARGS="${EXCLUDE_ARGS} --exclude ${ARG}"
done
The end result that I expect is to build the following:
--exclude /dev --exclude /sys --exclude /proc --exclude /tmp
--exclude /bin --exclude /usr/bin --exclude /usr/sbin --exclude /sbin
--exclude /lib --exclude /usr/lib --exclude *~
But, when each item in $EXCLUDED is evaluated to become $ARG, it appears
to undergo filename expansion. If no files fitting the pattern '*~'
exist in the current directory, it evaluates fine. On the other hand,
if there are files matching '*~', it expands to those filenames. I'd
like to suppress globbing while building that so that it works always,
but I actually don't know where to look on how. It seems that there
isn't a way around the expansion while evaluating the loop.
I hope I'm wrong. Am I?
--- Mike
More information about the Ale
mailing list