Problem in bin/sh stripping the * character through ${expansion%}

Johan van Selst johans at stack.nl
Thu Aug 6 18:38:50 UTC 2009


Doug Barton wrote:
> 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.

Your script does
	var=${var%\*}

When I tried it myself, I automatically typed quotes, which does work
	var="${var%\*}"

Alternatively you could use (with or without quotes)
	var="${var%[*]}"

Still, I don't see a reason why your variant shouldn't work as well..


Regards,
Johan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20090806/11e937fb/attachment.pgp


More information about the freebsd-hackers mailing list