|
From: | Chet Ramey |
Subject: | Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active |
Date: | Thu, 19 Dec 2024 11:08:26 -0500 |
User-agent: | Mozilla Thunderbird |
On 12/18/24 9:39 PM, Zachary Santer wrote:
If one wants to use funsubs that don't expand to anything as a workaround like this, it might be more efficient to use the ${| command; } form, as bash then isn't pointlessly redirecting stdout. The manual describes 'set -u'/'set -o nounset' thusly: Treat unset variables and parameters other than the special parameters “@” and “*”, or array variables subscripted with “@” or “*”, as an error when performing parameter expansion. If expansion is attempted on an unset variable or parameter, the shell prints an error message, and, if not interactive, exits with a non-zero status.
So you're saying that bash looking at a specific variable and using its value should fail if that variable is unset? How far do you want to take that? PS2? PS4? GLOBIGNORE? COMPREPLY? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
[Prev in Thread] | Current Thread | [Next in Thread] |