Nerius Landys wrote:
> Is there a function, or command line utility, to "escape" a string,
> making it suitable to be input on the command line? For example, this
> "escape" utility would take a input of "te st" and create an output of
> "te\ st". Other things such as quotes and single quotes w
>> #!/bin/sh
>>
>> DIRNAME="`dirname \"$0\"`"
>> cd "$DIRNAME"
>> SCRIPTDIR="`pwd`"
>>
>> What if I got rid of extra double quotes? Like this:
>>
>> DIRNAME=`dirname \"$0\"`
>> cd "$DIRNAME"
>> SCRIPTDIR=`pwd`
>
> That is perfectly fine. Word-splitting and filename expansion are
> not performed f
Nerius Landys wrote:
> #!/bin/sh
>
> DIRNAME="`dirname \"$0\"`"
> cd "$DIRNAME"
> SCRIPTDIR="`pwd`"
>
> What if I got rid of extra double quotes? Like this:
>
> DIRNAME=`dirname \"$0\"`
> cd "$DIRNAME"
> SCRIPTDIR=`pwd`
That is perfectly fine. Word-splitting and filename expansion are
not p
On 15.02.2010 09:21, Nerius Landys wrote:
> But in the case where you're assigning the output of ls directly to a
> variable like this:
>
> FOO=`ls`
>
> vs
>
> FOO="`ls`"
>
> the text assigned to FOO is the same, right?
Apparently, it is:
sh-4.0$ touch "x *"
sh-4.0$ FOO=`ls`;echo "$FOO"|od
00
> >From the man page:
>
> Command Substitution
> [...]
> If the substitution appears within double quotes, word splitting and
> pathname expansion are not performed on the results.
>
> In other words:
>
> sh-4.0$ touch "x y"
> sh-4.0$ for i in `ls`; do echo "$i"; done
> x
> y
> sh-4.0$ fo
On 15.02.2010 08:07, Nerius Landys wrote:
> DIRNAME="`dirname \"$0\"`"
> cd "$DIRNAME"
> SCRIPTDIR="`pwd`"
>
> What if I got rid of extra double quotes? Like this:
>
> DIRNAME=`dirname \"$0\"`
> cd "$DIRNAME"
> SCRIPTDIR=`pwd`
>
> Does this behave any differently in any kind of case? Are thes
#!/bin/sh
I have these lines in my script:
DIRNAME="`dirname \"$0\"`"
cd "$DIRNAME"
SCRIPTDIR="`pwd`"
What if I got rid of extra double quotes? Like this:
DIRNAME=`dirname \"$0\"`
cd "$DIRNAME"
SCRIPTDIR=`pwd`
Does this behave any differently in any kind of case? Are thes double
quotes just