[TriLUG] RE with bash
Joseph Mack NA3T
jmack at wm7d.net
Mon Oct 23 13:40:12 EDT 2006
running the script with sh -x I have
echo "directories=$directories"
gives
directories=A|Flash\ Player|foo
(where A is a directory that will be listed before Flash\
Player)
then I do
IFS="|"; for directory in $directories
do
echo "directory $directory"
cd $directory
cd ../
done
This goes fine for directory A.
Watching with 'sh -x' I see 'cd A'.
When the script gets to Flash\ Player the cd
command is
cd 'Flash\ Player'
(note single quotes) which fails.
It appears that bash is encapsulating Flash\ Player in the
single quotes otherwise the '\' doesn't survive.
$ directory=Flash\ Player
$ echo $directory
Flash Player
$ cd $directory #fails
instead, encapsulating the directory name, the '\' survives
but now you can't use it.
$ directory='Flash\ Player'
$ echo $directory
Flash\ Player
$ cd $directory #fails
however doing it by hand (non-programmatically)
$ cd Flash\ Player #works
other attempts
$ directory=Flash\\ Player #command Player not found
$ directory="Flash\\ Player"
$ echo $directory
Flash\ Player
$ cd $directory
Flash\ Player: no such file or directly
Any ideas on doing this programmatically?
Thanks Joe
--
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
More information about the TriLUG
mailing list