Date: Thu, 06 Aug 2009 11:15:12 -0700
From: Doug Barton <dougb@FreeBSD.org>
To: freebsd-hackers@freebsd.org
Subject: Problem in bin/sh stripping the * character through ${expansion%}
Message-ID: <4A7B1DB0.1040602@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Howdy,
I came across this problem during a recent portmaster update. When
trying to strip off the * character using variable expansion in bin/sh
it doesn't work. Other "special" characters do work if they are
properly escaped.
The attached mini-script clearly shows the problem:
$ sh sh-strip-problem
var before stripping: foo\*
var after stripping: foo\*
var before stripping: foo\$
var after stripping: foo\
In contrast, bash does the right thing:
bash sh-strip-problem
var before stripping: foo\*
var after stripping: foo\
var before stripping: foo\$
var after stripping: foo\
Should I go ahead and file a PR on this?
Doug
--
This .signature sanitized for your protection
[-- Attachment #2 --]
var='foo\*'
echo "var before stripping: $var"
var=${var%\*}
echo "var after stripping: $var"
echo ''
var='foo\$'
echo "var before stripping: $var"
var=${var%\$}
echo "var after stripping: $var"
exit 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A7B1DB0.1040602>
