From owner-svn-src-stable@FreeBSD.ORG Sat Feb 5 21:24:38 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 309491065673; Sat, 5 Feb 2011 21:24:38 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 054838FC15; Sat, 5 Feb 2011 21:24:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p15LObTm041445; Sat, 5 Feb 2011 21:24:37 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p15LObXg041442; Sat, 5 Feb 2011 21:24:37 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201102052124.p15LObXg041442@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 5 Feb 2011 21:24:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218346 - in stable/8: bin/sh tools/regression/bin/sh/expansion X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Feb 2011 21:24:38 -0000 Author: jilles Date: Sat Feb 5 21:24:37 2011 New Revision: 218346 URL: http://svn.freebsd.org/changeset/base/218346 Log: MFC r216496: sh: Fix corruption of command substitutions with special chars after newline. The CTLESC byte to protect a special character was output before instead of after a newline directly preceding the special character. The special handling of newlines is because command substitutions discard all trailing newlines. Added: stable/8/tools/regression/bin/sh/expansion/cmdsubst3.0 - copied unchanged from r216496, head/tools/regression/bin/sh/expansion/cmdsubst3.0 Modified: stable/8/bin/sh/expand.c Directory Properties: stable/8/bin/sh/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/expand.c ============================================================================== --- stable/8/bin/sh/expand.c Sat Feb 5 21:21:27 2011 (r218345) +++ stable/8/bin/sh/expand.c Sat Feb 5 21:24:37 2011 (r218346) @@ -470,8 +470,6 @@ expbackq(union node *cmd, int quoted, in } lastc = *p++; if (lastc != '\0') { - if (quotes && syntax[(int)lastc] == CCTL) - STPUTC(CTLESC, dest); if (lastc == '\n') { nnl++; } else { @@ -479,6 +477,8 @@ expbackq(union node *cmd, int quoted, in nnl--; STPUTC('\n', dest); } + if (quotes && syntax[(int)lastc] == CCTL) + STPUTC(CTLESC, dest); STPUTC(lastc, dest); } } Copied: stable/8/tools/regression/bin/sh/expansion/cmdsubst3.0 (from r216496, head/tools/regression/bin/sh/expansion/cmdsubst3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/cmdsubst3.0 Sat Feb 5 21:24:37 2011 (r218346, copy of r216496, head/tools/regression/bin/sh/expansion/cmdsubst3.0) @@ -0,0 +1,20 @@ +# $FreeBSD$ + +e= +for i in 0 1 2 3; do + for j in 0 1 2 3 4 5 6 7; do + for k in 0 1 2 3 4 5 6 7; do + case $i$j$k in + 000) continue ;; + esac + e="$e\n\\$i$j$k" + done + done +done +e1=$(printf "$e") +e2="$(printf "$e")" +[ "${#e1}" = 510 ] || echo length bad +[ "$e1" = "$e2" ] || echo e1 != e2 +[ "$e1" = "$(printf "$e")" ] || echo quoted bad +IFS= +[ "$e1" = $(printf "$e") ] || echo unquoted bad