bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read-only flag is lost for functions in sub shells


From: Chris F.A. Johnson
Subject: Re: read-only flag is lost for functions in sub shells
Date: Thu, 31 Jul 2014 15:36:26 -0400 (EDT)
User-agent: Alpine 2.10 (DEB 1266 2009-07-14)

On Thu, 31 Jul 2014, Chet Ramey wrote:
On 7/31/14, 10:51 AM, Linda Walsh wrote:
...
I thought the idea of RO vars being passed to children was considered
desirable?

As Greg says, there's no existing mechanism to do that using the
environment, which is the only way to communicate across exec(2).  I
could invent something, but what would be the point?

  It's not hard to do, e.g. as a comma-separated list of readonly
  variables:

export READONLY_VARS=foo,bar,why,not foo bar why not

  In the receiving script:

if [[ -n $READONLY_VARS ]]
then
  IFS=, read -a rov <<< "$READONLY_VARS"
  readonly "${rov[@]}"
fi
foo=q ## not permitted

--
Chris F.A. Johnson, <http://cfajohnson.com>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]