bashsupport-pro
bashsupport-pro copied to clipboard
In bash, ${diskSize:=0} is a variable assignment and default value setting command, but it is not recognized properly?
I can confirm that this is a bug. I'll fix it for the next update.
It's happening because ${diskSize:=0}
is inside a subshell and here BashSupport Pro is not applying the correct scoping.
The following works as expected:
diskSize=42
echo ${diskSize:=0}
This is fixed now for the next update
Inline arrays seem to have this problem?
@super-vip Yes, unfortunately that's a known issue. As a workaround, please quote the keys, e.g. ["red"]
.
(Please create new issue if it's not related to the current issue)
Bash determines at runtime how to interpret [red]
. For indexed arrays, it's an arithmetic expression (and red
would be a variable) and for associative arrays red
is a string value.
Here's an example:
#!/usr/bin/env bash
red=1
declare -a colorsIndexed
declare -A colorsAssociative
colorsIndexed=(
[red+10]="this is red+10"
)
colorsAssociative=(
[red+10]="this is red+10"
)
declare -p colorsIndexed
declare -p colorsAssociative
Output:
declare -a colorsIndexed=([11]="this is red+10")
declare -A colorsAssociative=([red+10]="this is red+10" )
Version 4.1.1 with the fix for the parameter expansion is now available.
Great, thank you. Upon testing, it has been confirmed that this issue has been resolved.