Bruce Dubbs wrote:
No. But the behavior is documented in the bash man page:
"When the old-style backquote form of substitution is used, backslash
retains its literal meaning except when followed by $, `, or \. The
first backquote not preceded by a backslash terminates the command
substitution. When using the $(command) form, all characters
between the parentheses make up the command; none are treated specially."
Well, taking Bruce's findings above into account, I seem to have found a
way to get the results Randy was looking for in the example he provided.
$ JUSTFORBRUCE=`echo ${BIGSTRING} | sed \
"s/^.*\($MYSTRING\).*$/\\\"${COUNTER}"/"`
$ echo $JUSTFORBRUCE
string
Notice the need for the extra backslash before ${COUNTER} as per the
bash man page above. Also, interestingly, the ${COUNTER} variable is
expanded only when it is surrounded by quotes.
Granted, the $(...) may be easier to work with because of these caveats,
but as it seems the behavior is known and documented, I'm not sure it's
correct to say that `...` is broken.
--
JH
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page