[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coproc and existing variables
From: |
Chet Ramey |
Subject: |
Re: coproc and existing variables |
Date: |
Thu, 19 May 2016 10:52:08 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
On 5/17/16 5:14 PM, Grisha Levit wrote:
> On Sun, Apr 24, 2016 at 2:17 PM, Chet Ramey <chet.ramey@case.edu
> <mailto:chet.ramey@case.edu>> wrote:
>
> it seems reasonable to follow printf/read/mapfile and not overwrite read-
> only variables used as coproc names. getopts will remain an outlier.
>
> getopts can probably benefit from a nameref check too, otherwise it can be
> exploited to unset arbitrary readonly variables.
>
> |$ declare -r RO=foo; declare -n OPTARG; getopts x x; declare -p RO bash:
> declare: RO: not found |
Existing practice across several shells is that getopts unsets OPTARG
whether or not it's readonly (and, at least in the case of ksh93/mksh,
does not honor any readonly setting at all, even on assignment), so it
would probably be best to just unset OPTARG when an unknown option is
encountered without following any nameref chain.
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/
- Re: coproc and existing variables, (continued)
- Re: coproc and existing variables, Grisha Levit, 2016/05/17
- Re: coproc and existing variables, Chet Ramey, 2016/05/19
- Re: coproc and existing variables, Grisha Levit, 2016/05/23
- Re: coproc and existing variables, Chet Ramey, 2016/05/23
- Re: coproc and existing variables, Grisha Levit, 2016/05/23
- Re: coproc and existing variables, Dan Douglas, 2016/05/24
- Re: coproc and existing variables, Chet Ramey, 2016/05/24
Re: coproc and existing variables, Grisha Levit, 2016/05/17