tree-sitter-bash/corpus/commands.txt

225 lines
3.9 KiB
Plaintext

===============================
Commands
===============================
whoami
---
(program
(command (command_name)))
===============================
Commands with arguments
===============================
cat file1.txt
cat -n file1.txt file2.txt
---
(program
(command (command_name) (argument))
(command (command_name) (argument) (argument) (argument)))
===============================
Commands with quoted arguments
===============================
echo "hello $(whoami), this is $(uname)"
echo 'hi'
---
(program
(command (command_name) (quoted_argument
(command_substitution (command (command_name)))
(command_substitution (command (command_name)))))
(command (command_name) (single_quoted_argument)))
===============================
Quoted command names
===============================
"$a/$b" c
---
(program
(command (quoted_argument (expansion (variable_name)) (expansion (variable_name))) (argument)))
===============================
Commands with numeric arguments
===============================
exit 1
---
(program
(command (command_name) (argument)))
===================================
Commands with environment variables
===================================
VAR1=1 ./script/test
VAR1=a VAR2="ok" git diff --word-diff=color
---
(program
(command
(environment_variable_assignment (variable_name) (argument))
(command_name))
(command
(environment_variable_assignment (variable_name) (argument))
(environment_variable_assignment (variable_name) (quoted_argument))
(command_name)
(argument)
(argument)))
===================================
Empty environment variables
===================================
VAR1=
VAR2= echo
---
(program
(environment_variable_assignment (variable_name))
(command (environment_variable_assignment (variable_name)) (command_name)))
===================================
Pipelines
===================================
whoami | cat
cat foo | grep -v bar
---
(program
(pipeline
(command (command_name))
(command (command_name)))
(pipeline
(command (command_name) (argument))
(command (command_name) (argument) (argument))))
===================================
Lists
===================================
a | b && c && d; d e f || e g
---
(program
(list
(list
(pipeline
(command (command_name))
(command (command_name)))
(command (command_name)))
(command (command_name)))
(list
(command (command_name) (argument) (argument))
(command (command_name) (argument))))
===============================
File redirects
===============================
whoami > /dev/null
cat a b > /dev/null
2>&1 whoami
---
(program
(command
(command_name)
(file_redirect (argument)))
(command
(command_name)
(argument)
(argument)
(file_redirect (argument)))
(command
(file_redirect (file_descriptor) (argument))
(command_name)))
===============================
Variable expansions
===============================
cat $FOO
---
(program
(command
(command_name)
(expansion (variable_name))))
===============================
Variable expansion operators
===============================
cat ${BAR} ${ABC=def} ${GHI:?jkl}
---
(program
(command
(command_name)
(operator_expansion (variable_name))
(operator_expansion (variable_name) (argument))
(operator_expansion (variable_name) (argument))))
===============================
Heredoc redirects
===============================
node <<JS
console.log("hi")
JS
bash -c <<JS
echo hi
JS
---
(program
(command
(command_name)
(heredoc_redirect (heredoc)))
(command
(command_name)
(argument)
(heredoc_redirect (heredoc))))
===============================
Heredocs with variables
===============================
node <<JS
a $B ${C}
JS
exit
---
(program
(command
(command_name)
(heredoc_redirect (heredoc
(expansion (variable_name))
(operator_expansion (variable_name)))))
(command (command_name)))