Re: [PATCHv5 16/16] Introduce portable_unset and use it to ensure proper && chaining
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Oct 3, 2010, 14:51 UTC
- Message-ID
- <20101003145122.GF17084@burratino>
- In-Reply-To
- <1286082644-31595-17-git-send-email-newren@gmail.com>
Elijah Newren wrote:
Show 9 quoted lines
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -268,6 +268,10 @@ remove_cr () {
> tr '\015' Q | sed -e 's/Q$//'
> }
>
> +portable_unset () {
> + unset $* || true
> +}I think this should read
portable_unset () {
unset "$@"
return 0
}(or || true). That is, if I try
portable_unset "foo bar"
then on platforms where an envvar named "foo bar" is allowed, this should unset it, no?
Also, maybe a comment could guide people in using this:
# In some bourne shell implementations, the "unset" builtin # returns nonzero status when a variable to be unset was not # set in the first place. # # Use portable_unset when that should not be considered an # error.
An update to t/README would be nice, too. :)