I came across the following problem using shgmt (v3.7.0) on the following valid bash code.
I am using hashes for associative arrays that contain dahes (in my example --shfmt-bug
However, shfmt insert blanks between --shfmt - bug, which breaks the array lookup:
test.sh:
#!/bin/bash
. lib.sh # defines readargs function
declare -A args
readargs args
echo "${args[--shfmt-bug]}
lib.sh
readargs() {
local -n _args
args[--shfmt-bug]="hello"
}
lib.sh is coming from a library, which isn't formatted with shfmt.
While my own code (represented by test.sh) is formatted with shfmt.
Because the blanks change the hash in a meaningful way, the array lookup fails.
I can use "--shfmt-bug" in my code to prevent shfmt from doing that, but I shouldn't have to.
Hi,
I came across the following problem using shgmt (v3.7.0) on the following valid bash code. I am using hashes for associative arrays that contain dahes (in my example --shfmt-bug However, shfmt insert blanks between --shfmt - bug, which breaks the array lookup:
test.sh:
lib.sh
lib.sh is coming from a library, which isn't formatted with shfmt. While my own code (represented by test.sh) is formatted with shfmt. Because the blanks change the hash in a meaningful way, the array lookup fails. I can use "--shfmt-bug" in my code to prevent shfmt from doing that, but I shouldn't have to.