From 9a10db163d5d8a4dd57a601a17ac79ecd28f66dd Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Thu, 22 Feb 2018 06:52:43 +0100 Subject: [PATCH] testsuite: check args handling in 070-stderrtty Set a directory with name starting by '$' to check if shell arguments are correctly escaped. Complements #154. --- testsuite/install.00-init/070-stderrtty.exp | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/testsuite/install.00-init/070-stderrtty.exp b/testsuite/install.00-init/070-stderrtty.exp index dbb5af40..69fe0a9c 100644 --- a/testsuite/install.00-init/070-stderrtty.exp +++ b/testsuite/install.00-init/070-stderrtty.exp @@ -89,12 +89,43 @@ foreach shell $othlang_list { testall_cmd "$shell" "use $contrib_modpath:load null:info-loaded null" $anstxt "" 0 } + +# set a directory with name starting by '$' to check if shell arguments are correctly escaped +set disruptive_dir "[pwd]/\$RE.BIN" +if {$verbose > 0} { + send_user "\tCreate disruptive directory $disruptive_dir\n" +} +file mkdir $disruptive_dir + +foreach shell $shell_list { + switch -- $shell { + {csh} - {tcsh} { + testall_cmd_re "$shell" "module --version" "^\$" "^Modules Release \\S+ (\\S+)\$" 0 + } + default { + testall_cmd_re "$shell" "module --version" "^Modules Release \\S+ (\\S+)\$" "^\$" 0 + } + } +} + +foreach shell $othlang_list { + testall_cmd_re "$shell" "--version" "^\$" "^Modules Release \\S+ (\\S+)\$" 0 +} + + +if {$verbose > 0} { + send_user "\tDelete disruptive directory $disruptive_dir\n" +} +file delete $disruptive_dir + + # # Clean up variables used in this test case # unset bad_cmd unset anstxt +unset disruptive_dir } elseif {$verbose > 0} { send_user "\tSkip test as STDERR is not attached to a TTY\n"