Substring Expansion doesn't respect IFS when using in Heredoc
Hello, I encountered something strange when using bash. It seems like a bug so someone suggested that I ask here. Here is the test code. declare -a arr=(12 34 56 78 90) IFS=',' cat <<<"${arr[*]:0}" cat <
Hierarchical data (was: Light weight support for JSON)
On Wed, Aug 31, 2022 at 11:11:26AM -0400, Chet Ramey wrote: On 8/29/22 2:03 PM, tetsu...@scope-eye.net wrote: It would also help greatly if the shell could internally handle hierarchical data in variables. That's a fundamental change. There would have to be a better reason to make it than handling JSON. I've only a little interest in handling JSON natively in bash (jq usually gets me there), but I have a strong interest in handling hierarchical data (h-data) in bash. I admit I've only had a few cases where I've been jumping through hoops to manage h-data in bash, but that's because, once it's clear h-data is a natural way to manage an issue, I would normally handle the problem in perl rather than trying to force clunky constructs into a bash script. In perl I use h-data all the time. I'm sure if h-data were available in bash I'd be using it all the time there as well. Chris
Re: Substring Expansion doesn't respect IFS when using in Heredoc
Someone in stackoverflow reminded me that this bug didn't exist before 5.0, so I did a bisect and the result shows that the bug was first introduced in 057a9fbd. BTW, the question link is https://stackoverflow.com/questions/73571977 Aloxaf Yin 于2022年9月2日周五 00:54写道: > > Hello, I encountered something strange when using bash. It seems like a bug > so someone suggested that I ask here. > > Here is the test code. > > declare -a arr=(12 34 56 78 90) > > IFS=',' > > cat <<<"${arr[*]:0}" > > cat < ${arr[*]:0} > ${arr[*]} > EOF > > The result is as follows. As you can see the comma is missing from the second > line. > > 12,34,56,78,90 > 12 34 56 78 90 > 12,34,56,78,90 > > bash: 5.1.16(1)-release > OS: Arch Linux > >