[pacman-dev] [PATCH 1/3] makepkg: use bash 4.4 to localize `set` without explicitly saving/restoring
Eli Schwartz
eschwartz at archlinux.org
Wed Aug 29 06:21:29 UTC 2018
On 8/29/18 2:18 AM, Allan McRae wrote:
> On 29/08/18 15:20, Eli Schwartz wrote:
>> On 8/29/18 12:54 AM, Allan McRae wrote:
>>> My understanding is this does not quite do the same thing... "local -"
>>> only save the single-letter shell options. There are set options that
>>> do not have a single letter variants (although they are unlikely to be
>>> used...).
>>
>> The manpage does not indicate this; it just says:
>>
>> the set of shell options is made local to the function in which local is
>> invoked: shell options changed using the set builtin inside the function
>> are restored to their original values when the function returns.
>>
>
> I was going off the bash-4.4 release notes.
Hmm, weird. :D
>> So...
>>
>> $ testfunc() { shopt -p -o pipefail; local -; set -o pipefail; shopt -p
>> -o pipefail; }
>> $ testfunc; shopt -p -o pipefail
>> set +o pipefail
>> set -o pipefail
>> set +o pipefail
>>
>> Seems to work okay, fortunately.
>
> Great. Patch is fine then. I'll adjust the comment to "localize set
> options" as "localize sets" is not clear.
No problem.
--
Eli Schwartz
Bug Wrangler and Trusted User
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20180829/dbfbda32/attachment.asc>
More information about the pacman-dev
mailing list