tree-sitter-bash/corpus/commands.txt

174 lines
3.3 KiB
Plaintext

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