2017-07-14 23:11:35 +00:00
|
|
|
====================================
|
|
|
|
While statements
|
|
|
|
====================================
|
|
|
|
|
|
|
|
while something happens; do
|
|
|
|
echo a
|
|
|
|
echo b
|
|
|
|
done
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(program
|
|
|
|
(while_statement
|
|
|
|
(command (command_name) (argument))
|
|
|
|
(do_group
|
|
|
|
(command (command_name) (argument))
|
|
|
|
(command (command_name) (argument)))))
|
2017-07-14 23:18:46 +00:00
|
|
|
|
|
|
|
====================================
|
|
|
|
If statements
|
|
|
|
====================================
|
|
|
|
|
|
|
|
if cat some_file | grep -v ok; then
|
|
|
|
echo one
|
|
|
|
elif cat other_file | grep -v ok; then
|
|
|
|
echo two
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(program
|
|
|
|
(if_statement
|
|
|
|
(pipeline
|
|
|
|
(command (command_name) (argument))
|
|
|
|
(command (command_name) (argument) (argument)))
|
|
|
|
(command (command_name) (argument))
|
|
|
|
(elif_clause
|
|
|
|
(pipeline
|
|
|
|
(command (command_name) (argument))
|
|
|
|
(command (command_name) (argument) (argument)))
|
|
|
|
(command (command_name) (argument)))
|
|
|
|
(else_clause
|
|
|
|
(command (command_name)))))
|