2017-07-14 19:28:54 +00:00
|
|
|
===============================
|
|
|
|
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))))))
|
2017-07-14 19:43:42 +00:00
|
|
|
|
|
|
|
===============================
|
|
|
|
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))))
|
2017-07-14 20:00:41 +00:00
|
|
|
|
2017-07-14 20:54:05 +00:00
|
|
|
===============================
|
|
|
|
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)))))
|
|
|
|
|
2017-07-14 21:27:13 +00:00
|
|
|
===============================
|
|
|
|
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))))
|
|
|
|
|
2017-07-14 20:00:41 +00:00
|
|
|
===============================
|
|
|
|
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)))))
|