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

bash: esc space not recognised in cat script ?



Hello again, more thorny bash escaped space problems ...
in $_tox is a file called "this is a test" ....
Below is the portion of code that is causing problems ....

for _scantox in $_tox/* ; do
_scantox=${_scantox// /\\ }

echo $_scantox

cat "$_scantox" | xmessage -fn 9x15 -center -buttons OK,Print,Delete -default OK -bg red
-file -
case $? in
       102) cat $_scantox | fmt -w 60 - | lpr;;
       103) rm $_scantox;;
       esac

The output is ... PS script called remind2

web@debian:/usr/local/myfiles/dave/debian/sh files$ ./remind2
/mnt/archive/remind/.tox/this\ is\ a\ test
cat: /mnt/archive/remind/.tox/this\ is\ a\ test: No such file or directory
web@debian:/usr/local/myfiles/dave/debian/sh files$
web@debian:/usr/local/myfiles/dave/debian/sh files$ ls /mnt/archive/remind/.tox/this\ is\ a\ test
/mnt/archive/remind/.tox/this is a test
web@debian:/usr/local/myfiles/dave/debian/sh files$
web@debian:/usr/local/myfiles/dave/debian/sh files$

the first echo shows the correct path+formatted file name, complete with escape chars
the cat $_scantox throws a wobbly, no such file.

If I cat from the command line, all is OK

web@debian:/usr/local/myfiles/dave/debian/sh files$
web@debian:/usr/local/myfiles/dave/debian/sh files$ cat /mnt/archive/remind/.tox/this\ is\ a\ test
yep sure is
web@debian:/usr/local/myfiles/dave/debian/sh files$

so what am I missing ? I just know it is going to be blindingly obvious ! I have tried quoting and not quoting cat "$_scantox"

Dave


PS I know I can give xmessage a file directly, using cat to simplify de-bugging, xmessage gives same fault.






Reply to: