#647
awk: length(array) silently returns zero for populated arrays
On just-bash 3.6.0 and current main (9ab0e0d3):
import { Bash } from "just-bash";
console.log(await new Bash().exec(
`awk 'BEGIN { split("a b",a," "); print length(a),a[1],a[2] }'`
));Expected stdout (gawk and macOS awk): 2 a b\n. Actual stdout: 0 a b\n, with empty stderr and exit status 0.
length() evaluates the array name as a scalar, gets an empty string, and returns zero. This silently produces wrong distinct-key counts in programs such as seen[$1]=1; ... length(seen).
Please support the array form by counting its elements, including array parameters, while preserving existing string/number/no-argument behavior. This is separate from the bare length parsing issue in #608.
Activity
0No activity yet.