Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Apr 2010 21:10:03 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/117748: commit references a PR
Message-ID:  <201004032110.o33LA3ol092980@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/117748; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/117748: commit references a PR
Date: Sat,  3 Apr 2010 21:08:04 +0000 (UTC)

 Author: jilles
 Date: Sat Apr  3 21:07:50 2010
 New Revision: 206147
 URL: http://svn.freebsd.org/changeset/base/206147
 
 Log:
   sh: Allow quoting pattern match characters in ${v%pat} and ${v#pat}.
   
   Note that this depends on r206145 for allowing pattern match characters to
   have their special meaning inside a double-quoted expansion like "${v%pat}".
   
   PR:		bin/117748
   Exp-run done by:	erwin (with some other sh(1) changes)
 
 Added:
   head/tools/regression/bin/sh/expansion/trim2.0   (contents, props changed)
 Modified:
   head/bin/sh/expand.c
 
 Modified: head/bin/sh/expand.c
 ==============================================================================
 --- head/bin/sh/expand.c	Sat Apr  3 21:01:01 2010	(r206146)
 +++ head/bin/sh/expand.c	Sat Apr  3 21:07:50 2010	(r206147)
 @@ -506,7 +506,9 @@ subevalvar(char *p, char *str, int strlo
  	int amount;
  
  	herefd = -1;
 -	argstr(p, 0);
 +	argstr(p, subtype == VSTRIMLEFT || subtype == VSTRIMLEFTMAX ||
 +	    subtype == VSTRIMRIGHT || subtype == VSTRIMRIGHTMAX ?
 +	    EXP_CASE : 0);
  	STACKSTRNUL(expdest);
  	herefd = saveherefd;
  	argbackq = saveargbackq;
 
 Added: head/tools/regression/bin/sh/expansion/trim2.0
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/bin/sh/expansion/trim2.0	Sat Apr  3 21:07:50 2010	(r206147)
 @@ -0,0 +1,55 @@
 +# $FreeBSD$
 +
 +e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
 +h='##'
 +failures=''
 +ok=''
 +
 +testcase() {
 +	code="$1"
 +	expected="$2"
 +	oIFS="$IFS"
 +	eval "$code"
 +	IFS='|'
 +	result="$#|$*"
 +	IFS="$oIFS"
 +	if [ "x$result" = "x$expected" ]; then
 +		ok=x$ok
 +	else
 +		failures=x$failures
 +		echo "For $code, expected $expected actual $result"
 +	fi
 +}
 +
 +set -f
 +testcase 'set -- $s'				'1|ast*que?non'
 +testcase 'set -- ${s%\?*}'			'1|ast*que'
 +testcase 'set -- "${s%\?*}"'			'1|ast*que'
 +testcase 'set -- ${s%\**}'			'1|ast'
 +testcase 'set -- "${s%\**}"'			'1|ast'
 +testcase 'set -- ${s%"$q"*}'			'1|ast*que'
 +testcase 'set -- "${s%"$q"*}"'			'1|ast*que'
 +testcase 'set -- ${s%"$a"*}'			'1|ast'
 +testcase 'set -- "${s%"$a"*}"'			'1|ast'
 +testcase 'set -- ${s%"$q"$a}'			'1|ast*que'
 +testcase 'set -- "${s%"$q"$a}"'			'1|ast*que'
 +testcase 'set -- ${s%"$a"$a}'			'1|ast'
 +testcase 'set -- "${s%"$a"$a}"'			'1|ast'
 +set +f
 +
 +testcase 'set -- "${b%\}}"'			'1|{{(#)}'
 +# Parentheses are special in ksh, check that they can be escaped
 +testcase 'set -- "${b%\)*}"'			'1|{{(#'
 +testcase 'set -- "${h#\#}"'			'1|#'
 +
 +testcase 'set -- ${p%"${p#?}"}'			'1|/'
 +testcase 'set -- ${p%"${p#??????}"}'		'1|/etc'
 +testcase 'set -- ${p%"${p#???????}"}'		'1|/etc/'
 +testcase 'set -- "${p%"${p#?}"}"'		'1|/'
 +testcase 'set -- "${p%"${p#??????}"}"'		'1|/et[c]'
 +testcase 'set -- "${p%"${p#???????}"}"'		'1|/et[c]/'
 +testcase 'set -- ${p#"${p}"}'			'0|'
 +testcase 'set -- "${p#"${p}"}"'			'1|'
 +testcase 'set -- "${p#*\[}"'			'1|c]/'
 +
 +test "x$failures" = x
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004032110.o33LA3ol092980>