Date: Sun, 20 Feb 2011 22:09:51 -0430 From: Andres Perera <andres.p@zoho.com> To: Warren Block <wblock@wonkity.com> Cc: questions@freebsd.org Subject: Re: Backtick versus $() Message-ID: <AANLkTim86PWJjpXA99F_fw5yR%2ByvRrBc=63=v5rEHzFJ@mail.gmail.com> In-Reply-To: <alpine.BSF.2.00.1102201027170.56885@wonkity.com> References: <alpine.BSF.2.00.1102201027170.56885@wonkity.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Feb 20, 2011 at 1:10 PM, Warren Block <wblock@wonkity.com> wrote: > > With backticks, the backreference \1 never seems to be replaced with the > actual pattern, regardless of search pattern. =C2=A0Tested on 8-stable an= d > 9-current. this isn't really new and it's not particular to freebsd sh(1) for i in bash dash mksh; do echo $i: $i <<'!' ra=3D` printf %s 's%\([?:.%\\]\)%\\\1%g'` rb=3D$(printf %s 's%\([?:.%\\]\)%\\\1%g') printf %s\\n "$ra" "$rb" ! done bash: s%\([?:.%\]\)%\\1%g s%\([?:.%\\]\)%\\\1%g dash: s%\([?:.%\]\)%\\1%g s%\([?:.%\\]\)%\\\1%g mksh: s%\([?:.%\]\)%\\1%g s%\([?:.%\\]\)%\\\1%g if you add another backslash to double-slashes in backticks: for i in bash dash mksh; do echo $i: && $i <<'!' echo $i: ra=3D` printf %s 's%\([?:.%\\\]\)%\\\\\1%g'` rb=3D$(printf %s 's%\([?:.%\\]\)%\\\1%g') printf %s\\n "$ra" "$rb" ! done bash: s%\([?:.%\\]\)%\\\1%g s%\([?:.%\\]\)%\\\1%g dash: s%\([?:.%\\]\)%\\\1%g s%\([?:.%\\]\)%\\\1%g mksh: s%\([?:.%\\]\)%\\\1%g s%\([?:.%\\]\)%\\\1%g no, backticks are not supposed to be equivalent
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTim86PWJjpXA99F_fw5yR%2ByvRrBc=63=v5rEHzFJ>