Subject: bin/2653: /bin/sh support for `#', `##', `%', `%%' var expansion modifiers broken within double quotes
To: None <gnats-bugs@NetBSD.ORG>
From: David Bronder <David-Bronder@uiowa.edu>
List: netbsd-bugs
Date: 07/23/1996 16:47:02
>Number:         2653
>Category:       bin
>Synopsis:       /bin/sh support for `#', `##', `%', `%%' var expansion modifiers broken within double quotes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 23 18:05:01 1996
>Last-Modified:
>Originator:     David Bronder
>Organization:
Center for Computer-Aided Design, University of Iowa
Iowa Student Computer Association, University of Iowa
>Release:        NetBSD-1.1
>Environment:
System: NetBSD mix 1.1_ALPHA NetBSD 1.1_ALPHA (GENERIC) #3: Thu Nov 16 18:45:14 PST 1995 thorpej@basalt:/tmp_mnt/bigsby/local/NetBSD-1.1/src/sys/arch/hp300/compile/GENERIC hp300


>Description:
	When `#', `##', `%', or `%%' variable expansion fails to match
	the given pattern, and the expression is within double quotes,
	the remainder of the quoted string is discarded with no further.
	Further variable expansion or backquote parsing is not performed,
	nor is the remainder of the string retained.


>How-To-Repeat:
	$ x=foo.c
	$ echo "${x%.c} bar"
	foo bar 
	$ x=foo
	$ echo "${x%.c} bar"
	foo


>Fix:
	The quoted string can be broken up into two quoted strings separated
	by whitespace.  This won't work if the remainder of the string past
	the expansion is not supposed to be separated by a space.

	$ x=foo
	$ echo "${x%.c}" "bar"
	foo bar


>Audit-Trail:
>Unformatted: