Date: Sun, 20 Feb 2011 10:40:47 -0700 (MST) From: Warren Block <wblock@wonkity.com> To: questions@freebsd.org Subject: Backtick versus $() Message-ID: <alpine.BSF.2.00.1102201027170.56885@wonkity.com>
next in thread | raw e-mail | index | archive | help
$() apparently isn't quite the same as backticks, although sh(1) doesn't
mention that, or I just missed it. This script is just supposed to
escape special characters* in a path/filename:
#!/bin/sh
DESTDIR="./"
COMPFILE=".cshrc"
PSTR=`echo "${DESTDIR}${COMPFILE}" | sed 's%\([?:.%\\]\)%\\\1%g'`
echo ${PSTR}
PSTR=$(echo "${DESTDIR}${COMPFILE}" | sed 's%\([?:.%\\]\)%\\\1%g')
% ./test.sh
\1/\1cshrc
\./\.cshrc
With backticks, the backreference \1 never seems to be replaced with the
actual pattern, regardless of search pattern. Tested on 8-stable and
9-current.
*: That's special characters as less(1) -Ps sees them.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1102201027170.56885>
