[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Effect of prefixed assignments on built-ins
From: |
Jens Schmidt |
Subject: |
Re: Effect of prefixed assignments on built-ins |
Date: |
Mon, 1 Jul 2024 21:18:11 +0200 |
User-agent: |
Mozilla Thunderbird |
On 2024-07-01 01:53, Emanuele Torre wrote:
> I don't think that is intended; it only happens when using declare -p
> without a specified variable, it does not happen if you use
> declare -p foo :
Thanks, your mail changed perspective for me: I somewhat assumed
that "read" is the outlier, but after your mail I scanned the
special variables and found more examples where a temp assignment
*does* have an effect on built-ins:
$ CDPATH=/usr cd lib
$ TMOUT=1 read
$ PATH=/tmp exec bash
or
$ echo "echo bar" > /tmp/foo
$ PATH=/tmp . foo
bar
or even
$ declare -a array=( a b c )
$ echo ${#array[@]}
3
$ index=2 unset 'array[index]'
$ echo ${#array[@]}
2
So yes, declare/export/set when operating on all variables really
seems to be the outlier here. Which is much easier to accept for me.
- Re: Effect of prefixed assignments on built-ins,
Jens Schmidt <=