Hi All,
I'm writing a script to start an application, which begins by doing
this:
#!/bin/sh
BASEDIR=`dirname "$0"`
BASEDIR=`echo $BASEDIR | sed -e 's/ /\\ /g'`
echo Got $BASEDIR
If I simulate what is going to happen (it's going to be started by a
.app) using the following from the Terminal, I get:
sh /Users/neil/Development/planb/build/dist/mac/PlanB\
Console.app/Contents/MacOS/planbconsole
Got /Users/neil/Development/planb/build/dist/mac/PlanB
Console.app/Contents/MacOS
Note that the Folder 'PlanB Console.app' has not been replaced with
'PlanB\ Console.app'.
Yet if I do the same sed command from the terminal, it works fine.
echo /Users/neil/Development/planb/build/dist/mac/PlanB
Console.app/Contents/MacOS | sed -e 's/ /\\ /g'
/Users/neil/Development/planb/build/dist/mac/PlanB\
Console.app/Contents/MacOS
Anyone got any clues?
matt neuburg - 10 Oct 2005 20:14 GMT
> Hi All,
> I'm writing a script to start an application, which begins by doing
[quoted text clipped - 23 lines]
>
> Anyone got any clues?
Why are you doing this at all? Just quote the pathname variable and let
interpolation happen. m.

Signature
matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/exec/obidos/ASIN/0596005571
Read TidBITS! It's free and smart. http://www.tidbits.com
Doc O'Leary - 10 Oct 2005 23:48 GMT
> Anyone got any clues?
Stop doing "printf" debugging. You're using echo twice in the script
but only once in Terminal. What should be important is what is in
BASEDIR, not what it prints as. Regardless, to get what you want, you'd
use:
echo Got "$BASEDIR"