From a2a74c0184bdde136356ada364eb2a5fc201f874 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 22 Sep 2021 03:41:04 +0300 Subject: [PATCH] chore: update tests for #101 --- corpus/commands.txt | 314 +++++++++++++------- corpus/literals.txt | 550 +++++++++++++++++++++++++---------- corpus/statements.txt | 653 +++++++++++++++++++++++++++++------------- 3 files changed, 1071 insertions(+), 446 deletions(-) diff --git a/corpus/commands.txt b/corpus/commands.txt index 4ae819db..9b3287aa 100644 --- a/corpus/commands.txt +++ b/corpus/commands.txt @@ -1,125 +1,179 @@ -=============================== +================================================================================ Commands -=============================== +================================================================================ whoami ---- +-------------------------------------------------------------------------------- (program - (command (command_name (word)))) + (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))) + (command + (command_name + (word)) + (word)) + (command + (command_name + (word)) + (word) + (word) + (word) + (word) + (word))) -=============================== +================================================================================ Quoted command names -=============================== +================================================================================ "$a/$b" c ---- +-------------------------------------------------------------------------------- (program (command - (command_name (string (simple_expansion (variable_name)) (simple_expansion (variable_name)))) + (command_name + (string + (str + (simple_expansion + (variable_name)) + (simple_expansion + (variable_name))))) (word))) -=============================== +================================================================================ Commands with numeric arguments -=============================== +================================================================================ exit 1 ---- +-------------------------------------------------------------------------------- (program - (command (command_name (word)) (word))) + (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))) + (variable_assignment + (variable_name) + (word)) + (command_name + (word))) (command - (variable_assignment (variable_name) (word)) - (variable_assignment (variable_name) (string)) - (command_name (word)) + (variable_assignment + (variable_name) + (word)) + (variable_assignment + (variable_name) + (string + (str))) + (command_name + (word)) (word) (word))) -=================================== +================================================================================ Empty environment variables -=================================== +================================================================================ VAR1= VAR2= echo ---- +-------------------------------------------------------------------------------- (program - (variable_assignment (variable_name)) - (command (variable_assignment (variable_name)) (command_name (word)))) + (variable_assignment + (variable_name)) + (command + (variable_assignment + (variable_name)) + (command_name + (word)))) -=============================== +================================================================================ File redirects -=============================== +================================================================================ whoami > /dev/null cat a b > /dev/null 2>&1 whoami ---- +-------------------------------------------------------------------------------- (program (redirected_statement - (command (command_name (word))) - (file_redirect (word))) + (command + (command_name + (word))) + (file_redirect + (word))) (redirected_statement - (command (command_name (word)) (word) (word)) - (file_redirect (word))) + (command + (command_name + (word)) + (word) + (word)) + (file_redirect + (word))) (command - (file_redirect (file_descriptor) (word)) - (command_name (word)))) + (file_redirect + (file_descriptor) + (word)) + (command_name + (word)))) -=============================== +================================================================================ File redirects (noclobber override) -=============================== +================================================================================ whoami >| /dev/null cat a b >| /dev/null ---- +-------------------------------------------------------------------------------- (program (redirected_statement - (command (command_name (word))) - (file_redirect (word))) + (command + (command_name + (word))) + (file_redirect + (word))) (redirected_statement - (command (command_name (word)) (word) (word)) - (file_redirect (word)))) - -=============================== + (command + (command_name + (word)) + (word) + (word)) + (file_redirect + (word)))) + +================================================================================ Heredoc redirects -=============================== +================================================================================ node < $tmpfile a $B ${C} @@ -172,54 +240,76 @@ EOF wc -l $tmpfile ---- +-------------------------------------------------------------------------------- (program (redirected_statement - (command (command_name (word))) - (heredoc_redirect (heredoc_start)) - (file_redirect (simple_expansion (variable_name)))) + (command + (command_name + (word))) + (heredoc_redirect + (heredoc_start)) + (file_redirect + (simple_expansion + (variable_name)))) (heredoc_body - (simple_expansion (variable_name)) - (expansion (variable_name))) + (simple_expansion + (variable_name)) + (expansion + (variable_name))) (command - (command_name (word)) + (command_name + (word)) (word) - (simple_expansion (variable_name)))) + (simple_expansion + (variable_name)))) -================================= +================================================================================ Heredocs with pipes -================================ +================================================================================ one < >(wc -c) ---- +-------------------------------------------------------------------------------- (program (command - (command_name (word)) + (command_name + (word)) (word) - (process_substitution (list - (command (command_name (word)) (word)) - (command (command_name (word)) (word))))) + (process_substitution + (list + (command + (command_name + (word)) + (word)) + (command + (command_name + (word)) + (word))))) (command - (command_name (word)) + (command_name + (word)) (word) (process_substitution - (command (command_name (word)) (word)) - (command (command_name (word)) (word)))) + (command + (command_name + (word)) + (word)) + (command + (command_name + (word)) + (word)))) (redirected_statement (command - (command_name (word)) + (command_name + (word)) (word)) - (file_redirect (process_substitution - (command (command_name (word)) (word)))))) - -============================= + (file_redirect + (process_substitution + (command + (command_name + (word)) + (word)))))) + +================================================================================ Single quoted strings -============================= +================================================================================ echo 'a b' 'c d' ---- +-------------------------------------------------------------------------------- (program - (command (command_name (word)) (raw_string) (raw_string))) + (command + (command_name + (word)) + (raw_string + (str)) + (raw_string + (str)))) -============================= +================================================================================ Double quoted strings -============================= +================================================================================ echo "a" "b" echo "a ${b} c" "d $e" ---- +-------------------------------------------------------------------------------- (program - (command (command_name (word)) - (string) - (string)) - (command (command_name (word)) - (string (expansion (variable_name))) - (string (simple_expansion (variable_name))))) - -========================================= + (command + (command_name + (word)) + (string + (str)) + (string + (str))) + (command + (command_name + (word)) + (string + (str + (expansion + (variable_name)))) + (string + (str + (simple_expansion + (variable_name)))))) + +================================================================================ Strings containing command substitutions -========================================= +================================================================================ find "`dirname $file`" -name "$base"'*' ---- +-------------------------------------------------------------------------------- (program (command - (command_name (word)) - (string (command_substitution (command (command_name (word)) (simple_expansion (variable_name))))) + (command_name + (word)) + (string + (str + (command_substitution + (command + (command_name + (word)) + (simple_expansion + (variable_name)))))) (word) (concatenation - (string (simple_expansion (variable_name))) - (raw_string)))) - -========================================= + (string + (str + (simple_expansion + (variable_name)))) + (raw_string + (str))))) + +================================================================================ Strings containing escape sequence -========================================= +================================================================================ echo "\"The great escape\`\${var}" ---- +-------------------------------------------------------------------------------- -(program (command (command_name (word)) (string))) +(program + (command + (command_name + (word)) + (string + (str)))) -====================================== +================================================================================ Strings containing special characters -====================================== +================================================================================ echo "s/$/'/" echo "#" echo "s$" ---- +-------------------------------------------------------------------------------- (program - (command (command_name (word)) (string)) - (command (command_name (word)) (string)) - (command (command_name (word)) (string))) + (command + (command_name + (word)) + (string + (str))) + (command + (command_name + (word)) + (string + (str))) + (command + (command_name + (word)) + (string + (str)))) -======================================== +================================================================================ Strings with ANSI-C quoting -======================================== +================================================================================ echo $'Here\'s johnny!\r\n' ---- +-------------------------------------------------------------------------------- -(program (command (command_name (word)) (ansii_c_string))) +(program + (command + (command_name + (word)) + (ansii_c_string + (str)))) -========================================= +================================================================================ Arrays and array expansions -========================================= +================================================================================ a=() b=(1 2 3) @@ -326,32 +528,66 @@ echo ${#b[@]} a[$i]=50 a+=(foo "bar" $(baz)) ---- +-------------------------------------------------------------------------------- (program - (variable_assignment (variable_name) (array)) - (variable_assignment (variable_name) (array (word) (word) (word))) - (command (command_name (word)) (expansion (subscript (variable_name) (word)))) - (command (command_name (word)) (expansion (subscript (variable_name) (word)))) (variable_assignment - (subscript (variable_name) (simple_expansion (variable_name))) + (variable_name) + (array)) + (variable_assignment + (variable_name) + (array + (word) + (word) + (word))) + (command + (command_name + (word)) + (expansion + (subscript + (variable_name) + (word)))) + (command + (command_name + (word)) + (expansion + (subscript + (variable_name) + (word)))) + (variable_assignment + (subscript + (variable_name) + (simple_expansion + (variable_name))) (word)) (variable_assignment (variable_name) (array (word) - (string) - (command_substitution (command (command_name (word))))))) - -============================== + (string + (str)) + (command_substitution + (command + (command_name + (word))))))) + +================================================================================ Escaped characters in strings -============================== +================================================================================ echo -ne "\033k$1\033\\" > /dev/stderr ---- +-------------------------------------------------------------------------------- (program (redirected_statement - (command (command_name (word)) (word) (string (simple_expansion (variable_name)))) - (file_redirect (word)))) + (command + (command_name + (word)) + (word) + (string + (str + (simple_expansion + (variable_name))))) + (file_redirect + (word)))) diff --git a/corpus/statements.txt b/corpus/statements.txt index 4c9de328..9319484d 100644 --- a/corpus/statements.txt +++ b/corpus/statements.txt @@ -1,95 +1,126 @@ -=================================== +================================================================================ Pipelines -=================================== +================================================================================ whoami | cat cat foo | grep -v bar ---- +-------------------------------------------------------------------------------- (program (pipeline (command - name: (command_name (word))) + name: (command_name + (word))) (command - name: (command_name (word)))) + name: (command_name + (word)))) (pipeline (command - name: (command_name (word)) + name: (command_name + (word)) argument: (word)) (command - name: (command_name (word)) + name: (command_name + (word)) argument: (word) argument: (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)))) + (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)))) + (command + (command_name + (word)) + (word) + (word)) + (command + (command_name + (word)) + (word)))) -==================================== +================================================================================ While statements -==================================== +================================================================================ while something happens; do echo a echo b done ---- +-------------------------------------------------------------------------------- (program (while_statement condition: (command - name: (command_name (word)) + name: (command_name + (word)) argument: (word)) body: (do_group - (command name: (command_name (word)) argument: (word)) - (command name: (command_name (word)) argument: (word))))) + (command + name: (command_name + (word)) + argument: (word)) + (command + name: (command_name + (word)) + argument: (word))))) -==================================== +================================================================================ While statements with IO redirects -==================================== +================================================================================ while read line; do echo $line done < <(cat file) ---- +-------------------------------------------------------------------------------- (program (redirected_statement body: (while_statement condition: (command - name: (command_name (word)) + name: (command_name + (word)) argument: (word)) body: (do_group (command - name: (command_name (word)) - argument: (simple_expansion (variable_name))))) + name: (command_name + (word)) + argument: (simple_expansion + (variable_name))))) redirect: (file_redirect - destination: (process_substitution (command - name: (command_name (word)) - argument: (word)))))) + destination: (process_substitution + (command + name: (command_name + (word)) + argument: (word)))))) -==================================== +================================================================================ For statements -==================================== +================================================================================ for a in 1 2 $(seq 5 10); do echo $a @@ -100,34 +131,40 @@ for ARG; do ARG='' done ---- +-------------------------------------------------------------------------------- (program (for_statement variable: (variable_name) value: (word) value: (word) - value: (command_substitution (command - name: (command_name (word)) - argument: (word) - argument: (word))) + value: (command_substitution + (command + name: (command_name + (word)) + argument: (word) + argument: (word))) body: (do_group (command - name: (command_name (word)) - argument: (simple_expansion (variable_name))))) + name: (command_name + (word)) + argument: (simple_expansion + (variable_name))))) (for_statement variable: (variable_name) body: (do_group (command - name: (command_name (word)) - argument: (simple_expansion (variable_name))) + name: (command_name + (word)) + argument: (simple_expansion + (variable_name))) (variable_assignment name: (variable_name) value: (raw_string))))) -==================================== +================================================================================ C-style for statements -==================================== +================================================================================ for (( c=1; c<=5; c++ )) do @@ -143,28 +180,44 @@ do echo 'forever' done ---- +-------------------------------------------------------------------------------- (program (c_style_for_statement (word) - (binary_expression (word) (word)) + (binary_expression + (word) + (word)) (word) (do_group - (command (command_name (word)) (simple_expansion (variable_name))))) + (command + (command_name + (word)) + (simple_expansion + (variable_name))))) (c_style_for_statement (word) - (binary_expression (word) (word)) + (binary_expression + (word) + (word)) (word) (compound_statement - (command (command_name (word)) (simple_expansion (variable_name))))) + (command + (command_name + (word)) + (simple_expansion + (variable_name))))) (c_style_for_statement (do_group - (command (command_name (word)) (raw_string))))) + (command + (command_name + (word)) + (raw_string + (str)))))) -==================================== +================================================================================ If statements -==================================== +================================================================================ if cat some_file | grep -v ok; then echo one @@ -174,42 +227,74 @@ else exit fi ---- +-------------------------------------------------------------------------------- (program (if_statement (pipeline - (command (command_name (word)) (word)) - (command (command_name (word)) (word) (word))) - (command (command_name (word)) (word)) + (command + (command_name + (word)) + (word)) + (command + (command_name + (word)) + (word) + (word))) + (command + (command_name + (word)) + (word)) (elif_clause (pipeline - (command (command_name (word)) (word)) - (command (command_name (word)) (word) (word))) - (command (command_name (word)) (word))) + (command + (command_name + (word)) + (word)) + (command + (command_name + (word)) + (word) + (word))) + (command + (command_name + (word)) + (word))) (else_clause - (command (command_name (word)))))) + (command + (command_name + (word)))))) -==================================== +================================================================================ If statements with conditional expressions -==================================== +================================================================================ if [ "$(uname)" == 'Darwin' ]; then echo one fi ---- +-------------------------------------------------------------------------------- (program (if_statement - (test_command (binary_expression - (string (command_substitution (command (command_name (word))))) - (raw_string))) - (command (command_name (word)) (word)))) + (test_command + (binary_expression + (string + (str + (command_substitution + (command + (command_name + (word)))))) + (raw_string + (str)))) + (command + (command_name + (word)) + (word)))) -==================================== +================================================================================ Case statements -==================================== +================================================================================ case "opt" in a) @@ -234,69 +319,122 @@ case $dest in ;; esac ---- +-------------------------------------------------------------------------------- (program - (case_statement (string) - (case_item (word) - (command (command_name (word)) (word))) - (case_item (word) - (command (command_name (word)) (word))) - (case_item (word) - (command (command_name (word)) (word)))) - (case_statement (string (simple_expansion (variable_name))) - (case_item (word) (word) - (command (command_name (word))))) - (case_statement (simple_expansion (variable_name)) - (case_item (concatenation (word) (word)) - (command (command_name (word)) (simple_expansion (special_variable_name)))))) - -============================= + (case_statement + (string + (str)) + (case_item + (word) + (command + (command_name + (word)) + (word))) + (case_item + (word) + (command + (command_name + (word)) + (word))) + (case_item + (word) + (command + (command_name + (word)) + (word)))) + (case_statement + (string + (str + (simple_expansion + (variable_name)))) + (case_item + (word) + (word) + (command + (command_name + (word))))) + (case_statement + (simple_expansion + (variable_name)) + (case_item + (concatenation + (word) + (word)) + (command + (command_name + (word)) + (simple_expansion + (special_variable_name)))))) + +================================================================================ Test commands -============================= +================================================================================ if [[ "$lsb_dist" != 'Ubuntu' || $(ver_to_int "$lsb_release") < $(ver_to_int '14.04') ]]; then return 1 fi ---- +-------------------------------------------------------------------------------- (program (if_statement - (test_command (binary_expression + (test_command (binary_expression (binary_expression - (string (simple_expansion (variable_name))) - (raw_string)) - (command_substitution (command - (command_name (word)) - (string (simple_expansion (variable_name)))))) - (command_substitution (command (command_name (word)) (raw_string))))) - (command (command_name (word)) (word)))) - + (binary_expression + (string + (str + (simple_expansion + (variable_name)))) + (raw_string + (str))) + (command_substitution + (command + (command_name + (word)) + (string + (str + (simple_expansion + (variable_name))))))) + (command_substitution + (command + (command_name + (word)) + (raw_string + (str)))))) + (command + (command_name + (word)) + (word)))) -============================= +================================================================================ Test commands with ternary -============================= +================================================================================ if (( 1 < 2 ? 1 : 2 )); then return 1 fi ---- +-------------------------------------------------------------------------------- (program (if_statement (test_command (ternary_expression - (binary_expression (word) (word)) - (word) (word))) + (binary_expression + (word) + (word)) + (word) + (word))) (command - (command_name (word)) (word)))) + (command_name + (word)) + (word)))) -============================= +================================================================================ Test commands with regexes -============================= +================================================================================ [[ "35d8b" =~ ^[0-9a-fA-F] ]] [[ $CMD =~ (^|;)update_terminal_cwd($|;) ]] @@ -308,64 +446,94 @@ Test commands with regexes [[ "$server" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]] [[ "$primary_wins" =~ ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) ]] ---- +-------------------------------------------------------------------------------- (program (test_command (binary_expression - (string) + (string + (str)) (regex))) (test_command (binary_expression - (simple_expansion (variable_name)) + (simple_expansion + (variable_name)) (regex))) (test_command (unary_expression (binary_expression - (string (expansion (subscript (variable_name) (word)))) - (string (simple_expansion (variable_name)))))) + (string + (str + (expansion + (subscript + (variable_name) + (word))))) + (string + (str + (simple_expansion + (variable_name))))))) (negated_command (test_command (binary_expression - (string (simple_expansion (variable_name))) + (string + (str + (simple_expansion + (variable_name)))) (regex)))) (test_command (binary_expression - (string (simple_expansion (variable_name))) + (string + (str + (simple_expansion + (variable_name)))) (regex))) (test_command (binary_expression - (string (simple_expansion (variable_name))) + (string + (str + (simple_expansion + (variable_name)))) (regex))) (test_command (binary_expression - (expansion (variable_name)) + (expansion + (variable_name)) (regex))) (test_command (binary_expression - (string (simple_expansion (variable_name))) + (string + (str + (simple_expansion + (variable_name)))) (regex))) (test_command (binary_expression - (string (simple_expansion (variable_name))) + (string + (str + (simple_expansion + (variable_name)))) (regex)))) -=============================== +================================================================================ Subshells -=============================== +================================================================================ ( ./start-server --port=80 ) & ---- +-------------------------------------------------------------------------------- (program - (subshell (command (command_name (word)) (word)))) + (subshell + (command + (command_name + (word)) + (word)))) -=============================== +================================================================================ Function definitions -=============================== +================================================================================ do_something() { echo ok @@ -385,98 +553,139 @@ function do_yet_another_thing { echo ok } 2>&1 ---- +-------------------------------------------------------------------------------- (program (function_definition (word) - (compound_statement (command (command_name (word)) (word)))) + (compound_statement + (command + (command_name + (word)) + (word)))) (function_definition - (word) - (subshell (command (command_name (word))))) + (word) + (subshell + (command + (command_name + (word))))) (function_definition - (word) - (test_command (unary_expression (test_operator) (word)))) + (word) + (test_command + (unary_expression + (test_operator) + (word)))) (function_definition (word) (compound_statement (pipeline - (command (command_name (word))) (command - (command_name (word)) - (concatenation (word)) + (command_name + (word))) + (command + (command_name + (word)) + (concatenation + (word)) (word) - (concatenation (word)) + (concatenation + (word)) (word) (word))))) - (redirected_statement (function_definition - (word) - (compound_statement (command (command_name (word)) (word)))) - (file_redirect (file_descriptor) (word)))) - -========================================= + (redirected_statement + (function_definition + (word) + (compound_statement + (command + (command_name + (word)) + (word)))) + (file_redirect + (file_descriptor) + (word)))) + +================================================================================ Variable declaration: declare & typeset -========================================= +================================================================================ declare var1 typeset -i -r var2=42 var3=10 ---- +-------------------------------------------------------------------------------- (program - (declaration_command (variable_name)) - (declaration_command (word) (word) - (variable_assignment (variable_name) (word)) - (variable_assignment (variable_name) (word)))) - -========================================= + (declaration_command + (variable_name)) + (declaration_command + (word) + (word) + (variable_assignment + (variable_name) + (word)) + (variable_assignment + (variable_name) + (word)))) + +================================================================================ Variable declaration: readonly -========================================= +================================================================================ readonly var1 readonly var2=42 ---- +-------------------------------------------------------------------------------- (program - (declaration_command (variable_name)) - (declaration_command (variable_assignment (variable_name) (word)))) + (declaration_command + (variable_name)) + (declaration_command + (variable_assignment + (variable_name) + (word)))) -========================================= +================================================================================ Variable declaration: local -========================================= +================================================================================ local a=42 b local -r c ---- +-------------------------------------------------------------------------------- (program (declaration_command - (variable_assignment (variable_name) (word)) + (variable_assignment + (variable_name) + (word)) (variable_name)) (declaration_command (word) (variable_name))) -========================================= +================================================================================ Variable declaration: export -========================================= +================================================================================ export PATH export FOOBAR PATH="$PATH:/usr/foobar/bin" ---- +-------------------------------------------------------------------------------- (program - (declaration_command (variable_name)) + (declaration_command + (variable_name)) (declaration_command (variable_name) - (variable_assignment (variable_name) (string (simple_expansion (variable_name)))))) - -=========================================================== + (variable_assignment + (variable_name) + (string + (str + (simple_expansion + (variable_name))))))) + +================================================================================ Variable declaration: command substitution with semi-colon -=========================================================== +================================================================================ _path=$( while statement; do @@ -485,51 +694,84 @@ _path=$( echo $PWD ) ---- +-------------------------------------------------------------------------------- (program - (variable_assignment (variable_name) + (variable_assignment + (variable_name) (command_substitution (while_statement - (command (command_name (word))) - (do_group (command (command_name (word)) (string)))) - (command (command_name (word)) (simple_expansion (variable_name)))))) + (command + (command_name + (word))) + (do_group + (command + (command_name + (word)) + (string + (str))))) + (command + (command_name + (word)) + (simple_expansion + (variable_name)))))) -=========================================== +================================================================================ Expressions passed to declaration commands -=========================================== +================================================================================ export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}" ---- +-------------------------------------------------------------------------------- (program (declaration_command (string - (command_substitution - (pipeline - (command (command_name (word)) (expansion (variable_name))) - (command (command_name (word)) (concatenation (word)) (concatenation (word))))) - (expansion (variable_name) (word))))) - -========================================= + (str + (command_substitution + (pipeline + (command + (command_name + (word)) + (expansion + (variable_name))) + (command + (command_name + (word)) + (concatenation + (word)) + (concatenation + (word))))) + (expansion + (variable_name) + (word)))))) + +================================================================================ Unset commands -========================================= +================================================================================ unset A unset "$variable_name" unsetenv -f ONE TWO ---- +-------------------------------------------------------------------------------- (program - (unset_command (variable_name)) - (unset_command (string (simple_expansion (variable_name)))) - (unset_command (word) (variable_name) (variable_name))) + (unset_command + (variable_name)) + (unset_command + (string + (str + (simple_expansion + (variable_name))))) + (unset_command + (word) + (variable_name) + (variable_name))) -=========================================== +================================================================================ Compound statements -=========================================== +================================================================================ a () { ls || { echo "b"; return 0; } @@ -540,16 +782,41 @@ a () { echo "b" } >&2 ---- +-------------------------------------------------------------------------------- (program - (function_definition (word) (compound_statement - (list - (command (command_name (word))) - (compound_statement - (command (command_name (word)) (string)) - (command (command_name (word)) (word)))) - (command (command_name (word)) (word)))) + (function_definition + (word) + (compound_statement + (list + (command + (command_name + (word))) + (compound_statement + (command + (command_name + (word)) + (string + (str))) + (command + (command_name + (word)) + (word)))) + (command + (command_name + (word)) + (word)))) (redirected_statement - (compound_statement (command (command_name (word)) (string)) (command (command_name (word)) (string))) - (file_redirect (word)))) + (compound_statement + (command + (command_name + (word)) + (string + (str))) + (command + (command_name + (word)) + (string + (str)))) + (file_redirect + (word))))