help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Backquote form of command substitution within double quo


From: Stephane Chazelas
Subject: Re: [Help-bash] Backquote form of command substitution within double quotes
Date: Tue, 23 Jun 2015 11:09:56 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-06-22 15:15:32 -0700, Michael Convey:
[...]
> Is the first undefined case described by the following?
> command "`command "argu`"ment"
> 
> Is the second undefined case described by the following?
> command "`command" argument`
> 
> I'm not sure I understand these undefined cases (especially the 2nd one).
> Thoughts?

For portability with ksh or the Bourne shell, you need:

echo "`echo \"foo  bar\"` baz"'

$ ksh -c 'echo "`echo "foo  bar"` baz"'
ksh: baz: not found [No such file or directory]
foo bar

The above is treated as:

echo "$(echo )"foo  bar"$( baz)"

If you have to use `...`, my advise would be to use intermediary
variables, not quote the command substitutions (in those
variable assignments) and not nest them:

var=`echo "foo  bar"`
echo "$var baz"

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]