|
From: | Grisha Levit |
Subject: | Re: coproc and existing variables |
Date: | Mon, 16 May 2016 16:44:59 -0400 |
A couple of minor things after the change (i don’t know if they’re worth looking at..)
$ declare -n ref=x; coproc ref { :; }; wait; declare -p ref
[1] 13267
[1]+ Done coproc ref { :; }
declare -an ref=([0]="x")
$ declare -r RO RO_PID; coproc RO { :; }; wait; declare -p RO RO_PID
bash: RO: readonly variable
[1] 13288
[1]+ Done coproc RO { :; }
bash: wait: RO: cannot unset: readonly variable
declare -r RO
bash: declare: RO_PID: not found
Yes, even though the restricted shell is not a great example of anything,On 4/21/16 2:39 PM, Grisha Levit wrote:
> On Thu, Apr 21, 2016 at 1:22 PM, Chet Ramey <chet.ramey@case.edu> wrote:
>>
>>> 1. coproc unsets readonly NAME after the process completes
>>
>> Yes. This is a gray area. Under some circumstances, e.g, getopts with
>> OPTARG, defined shell behavior can override a readonly setting.
>
> Probably should at least disallow this case?
>
> $ bash -r -c 'coproc PATH { :; }; wait; PATH=/whatever; echo $PATH'
> bash: PATH: readonly variable
> bash: PATH: readonly variable
> /whatever
it seems reasonable to follow printf/read/mapfile and not overwrite read-
only variables used as coproc names. getopts will remain an outlier.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
[Prev in Thread] | Current Thread | [Next in Thread] |