Open
Description
When trying to format shell script containing the bash syntax for closing a file
descriptor, shfmt
inserts a space between the variable part and the redirector
part.
Running
echo 'exec {variable_name[1]}<&-' | shfmt -ln=bash --diff
results in
diff <standard input>.orig <standard input>
--- <standard input>.orig
+++ <standard input>
@@ -1,1 +1,1 @@
-exec {variable_name[1]}<&-
+exec {variable_name[1]} <&-
which is invalid bash syntax.
See this sentence from REDIRECTIONS
from man bash(1)
If >&- or <&- is preceded by {varname}, the value of varname defines the file descriptor to close.
$ shfmt --version
v3.10.0
Metadata
Assignees
Labels
No labels
Activity