From owner-freebsd-questions@FreeBSD.ORG Mon Feb 21 03:03:11 2011 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 814B0106566B for ; Mon, 21 Feb 2011 03:03:11 +0000 (UTC) (envelope-from 839273@gmail.com) Received: from mail-yi0-f54.google.com (mail-yi0-f54.google.com [209.85.218.54]) by mx1.freebsd.org (Postfix) with ESMTP id 398D68FC08 for ; Mon, 21 Feb 2011 03:03:10 +0000 (UTC) Received: by yie19 with SMTP id 19so2406290yie.13 for ; Sun, 20 Feb 2011 19:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:reply-to:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=0QcvJIYY8euaJq2WvKNGftBbbOtdTf0fxJ1xp6ypCOI=; b=f4HdrheN/goKUxf5hKAwlKtFXXORzxyB0jHg/0SwrLXBrZECLEmq/jzJ1pipv8mddc Ay4OF8PiPLl6TirDNTpTmGJbA30GLc4w/8uOLWO6Edho576wntIQ67hbpKoP2N+G5P4v wLhdbNqK29D5vfyAyOoN9ndMRYVXXQscKeLoQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=vi0Ij9szY5WSq4WX6ptc2DSULYWXX9drrX0E0BIJOZtwevPJBRRTam26OCKV7qBhB7 4BIpenA3cxSHgQVVmqlMPX8zIfxnj6rzWJS6h1zQ5HiRTVM9fUZ3dLaSgUSq4Rd5u4Vn P32LYGO/HTWXydz1PP2pjbbNdzAyce5LT2618= MIME-Version: 1.0 Received: by 10.150.192.1 with SMTP id p1mr1063557ybf.116.1298255991723; Sun, 20 Feb 2011 18:39:51 -0800 (PST) Sender: 839273@gmail.com Received: by 10.151.110.10 with HTTP; Sun, 20 Feb 2011 18:39:51 -0800 (PST) In-Reply-To: References: Date: Sun, 20 Feb 2011 22:09:51 -0430 X-Google-Sender-Auth: W3iks64Zu_Ab8zNSOsjkqVieyPM Message-ID: From: Andres Perera To: Warren Block Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: questions@freebsd.org Subject: Re: Backtick versus $() X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: 839273@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Feb 2011 03:03:11 -0000 On Sun, Feb 20, 2011 at 1:10 PM, Warren Block 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