Incorrect comment detection inside Bash parameter expansion
josephcsible opened this issue · comments
The /*
in fd=${fd/*\/}
is considered to be the beginning of of a comment, when in fact it is not. This makes the rest of the script be seen and highlighted as a comment. Seen in the wild here: https://unix.stackexchange.com/a/429405/217726
clear_fds() {
for fd in $(compgen -G "/proc/$BASHPID/fd/*"); do
fd=${fd/*\/}
if [[ ! " $* " =~ " ${fd} " ]]; then
case "$fd" in
0|1|2|255)
;;
*)
eval "exec $fd>&-"
;;
esac
fi
done
}
Never mind, this was because the language wasn't getting passed correctly.