Re: [@]@A weird behaviour when IFS does not contain space
On 7/4/24 2:51 AM, Emanuele Torre wrote: Hello. Normally, ${foo[@]@A} expands to multiple values, that are the arguments to run a declare command that sets foo to the current value/attributes. bash-5.2$ a=( abc xyz 123 ); declare -pa result=("${a[@]@A}") declare -a result=([0]="declare" [1]="-a" [2]="a=([0]=\"abc\" [1]=\"xyz\" [2]=\"123\")") bash-5.2$ a=( abc xyz 123 ); echoargs "${a[@]@A}" $1='declare' $2='-a' $3='a=([0]="abc" [1]="xyz" [2]="123")' Today, I have noticed that if IFS is set to a value that does not include space, [@]@A will expand to a single value OK. Is that a problem? The man page says "when evaluated," and running the result through `eval' -- properly quoted -- produces the expected results. If there's an issue with making the expansion eval-safe, let's look at that. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: [@]@A weird behaviour when IFS does not contain space
On Wed, Jul 10, 2024 at 09:24:03AM -0400, Chet Ramey wrote: > On 7/4/24 2:51 AM, Emanuele Torre wrote: > > Hello. > > > > Normally, ${foo[@]@A} expands to multiple values, that are the arguments > > to run a declare command that sets foo to the current value/attributes. > > > > bash-5.2$ a=( abc xyz 123 ); declare -pa result=("${a[@]@A}") > > declare -a result=([0]="declare" [1]="-a" [2]="a=([0]=\"abc\" > > [1]=\"xyz\" [2]=\"123\")") > > bash-5.2$ a=( abc xyz 123 ); echoargs "${a[@]@A}" > > $1='declare' > > $2='-a' > > $3='a=([0]="abc" [1]="xyz" [2]="123")' > > > > Today, I have noticed that if IFS is set to a value that does not > > include space, [@]@A will expand to a single value > > OK. Is that a problem? The man page says "when evaluated," and running the > result through `eval' -- properly quoted -- produces the expected results. > If there's an issue with making the expansion eval-safe, let's look at that. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer >``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/ > I was curious about why it expands to multiple values if IFS is unset or is set to a string that contains at least a ' ' character, but it expands to a single value if IFS is set to any string that does not contain any ' ' characters. There is no obvious explanation for that, so that suggests there is something weird going on with this particular kind of expansion. "${a[@]@A}" o/ emanuele6
Re: proposed BASH_SOURCE_PATH
On 7/7/24 3:34 PM, Greg Wooledge wrote: At this point, I'm just going to wait and see what gets implemented, and then figure out how that affects scripts and interactive shells in the future. I added -p to ./source, but that's it. It's in the devel branch. There's no reason to continue discussing BASH_SOURCE_PATH, and the BASH_SOURCE absolute pathname discussion has been bananas, so that's not going in any time soon. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/