tree-sitter-bash/corpus/commands.txt

199 lines
3.5 KiB
Plaintext

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