File tree Expand file tree Collapse file tree 7 files changed +15
-7
lines changed
Expand file tree Collapse file tree 7 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ Modules 5.6.0 (not yet released)
2626* Doc: add :ref: `acknowledgments ` page in the documentation.
2727* Doc: describe :ref: `GOVERNANCE `.
2828* Doc: add :ref: `CHARTER `.
29+ * Escape square brackets (``[] ``) used in values within produced shell code as
30+ these characters may have special meaning on some shells (like *csh *). (fix
31+ issue #565)
2932
3033.. _Security policy : https://github.com/envmodules/modules/blob/main/SECURITY.md
3134
Original file line number Diff line number Diff line change 2020
2121# #########################################################################
2222
23- proc charEscaped {str {charlist " \\\\\t {}|<>!;#^\$ &*?\" '`()" }} {
23+ proc charEscaped {str {charlist " \\\\\t {}\\\[\\\] |<>!;#^\$ &*?\" '`()" }} {
2424 return [regsub -all "\(\[ $charlist \]\) " $str {\\\1}]
2525}
2626
27- proc charUnescaped {str {charlist " \\\\\t {}|<>!;#^\$ &*?\" '`()" }} {
27+ proc charUnescaped {str {charlist " \\\\\t {}\\\[\\\] |<>!;#^\$ &*?\" '`()" }} {
2828 return [regsub -all "\\\\\(\[ $charlist \]\) " $str {\1}]
2929}
3030
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ proc shell_val {test_shell val {re_mode 0}} {
234234 if {$val ne "(.*)"} {
235235 switch -- $test_shell {
236236 {sh} - {bash} - {ksh} - {zsh} - {csh} - {tcsh} - {fish} {
237- set val [regsub -all {([\\"'$|<>{}`*? ()!&;])} $val {\\\1}]
237+ set val [regsub -all {([\\"'$|<>{}`*? ()!&;\[\] ])} $val {\\\1}]
238238 }
239239 {lisp} - {cmake} {
240240 set val [regsub -all {(["])} $val {\\\1}]
Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ if {[find_bin grep] ne "" && [find_bin tr] ne "" && [find_bin awk] ne ""} {
4747 foreach shell $shell_list {
4848 if {$shell eq {csh} || $shell eq {tcsh}} {
4949 # alias evaluation leads to a syntax error if wa_277 is enabled
50- testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2" [expr {$install_wa277 eq {y} ? {} : "Release\nhttp://an.example.web\\?¶m=one"}] ".*" [expr {$install_wa277 eq {y} ? 1 : 0}]
50+ testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2; ts3 " [expr {$install_wa277 eq {y} ? {} : "Release\nhttp://an.example.web\\?¶m=one\nselect\\\[type==BAR && osrel==FOO\\\] myapp "}] ".*" [expr {$install_wa277 eq {y} ? 1 : 0}]
5151 } else {
52- testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2" "Release\nhttp://an.example.web\\?¶m=one" ".*" 0
52+ testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2; ts3 " "Release\nhttp://an.example.web\\?¶m=one\nselect\\\[type==BAR && osrel==FOO\\\] myapp " ".*" 0
5353 }
5454 }
5555} elseif {$verbose} {
Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ if {[find_bin grep] ne "" && [find_bin tr] ne "" && [find_bin awk] ne ""} {
5050 foreach shell $shell_list {
5151 if {$shell eq {csh} || $shell eq {tcsh}} {
5252 # alias evaluation leads to a syntax error if wa_277 is enabled
53- testall_cmd_re "$shell" "ml $testsuite_modpath/alias/3.0\; testsuite; ts2" [expr {$install_wa277 eq {y} ? {} : "Release\nhttp://an.example.web\\?¶m=one"}] ".*" [expr {$install_wa277 eq {y} ? 1 : 0}]
53+ testall_cmd_re "$shell" "ml $testsuite_modpath/alias/3.0\; testsuite; ts2; ts3 " [expr {$install_wa277 eq {y} ? {} : "Release\nhttp://an.example.web\\?¶m=one\nselect\\\[type==BAR && osrel==FOO\\\] myapp "}] ".*" [expr {$install_wa277 eq {y} ? 1 : 0}]
5454 } else {
55- testall_cmd_re "$shell" "ml $testsuite_modpath/alias/3.0\; testsuite; ts2" "Release\nhttp://an.example.web\\?¶m=one" ".*" 0
55+ testall_cmd_re "$shell" "ml $testsuite_modpath/alias/3.0\; testsuite; ts2; ts3 " "Release\nhttp://an.example.web\\?¶m=one\nselect\\\[type==BAR && osrel==FOO\\\] myapp " ".*" 0
5656 }
5757 }
5858} elseif {$verbose} {
Original file line number Diff line number Diff line change @@ -38,3 +38,5 @@ switch -- [module-info shelltype] {
3838
3939# check '?' and '&' are correctly escaped
4040set-alias ts2 {echo "http://an.example.web?¶m=one"}
41+ # check '[' and ']' are correctly escaped
42+ set-alias ts3 "echo \"select\[type==BAR && osrel==FOO\]\" myapp"
Original file line number Diff line number Diff line change @@ -87,20 +87,23 @@ lappend ans [list set __MODULES_LMREFRESH $module]
8787lappend ans [list set _LMFILES_ $modulefile]
8888lappend ans [list set LOADEDMODULES $module]
8989lappend ans [list alias ts2 {echo "http://an.example.web?¶m=one"}]
90+ lappend ans [list alias ts3 {echo "select[type==BAR && osrel==FOO]" myapp}]
9091lappend ans [list alias testsuite {echo $(grep "report .Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}')}]
9192
9293set ans2 [list]
9394lappend ans2 [list set __MODULES_LMREFRESH $module]
9495lappend ans2 [list set _LMFILES_ $modulefile]
9596lappend ans2 [list set LOADEDMODULES $module]
9697lappend ans2 [list alias ts2 {echo "http://an.example.web?¶m=one"}]
98+ lappend ans2 [list alias ts3 {echo "select[type==BAR && osrel==FOO]" myapp}]
9799lappend ans2 [list alias testsuite {echo `grep "report .Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}'`}]
98100
99101set ans3 [list]
100102lappend ans3 [list set __MODULES_LMREFRESH $module]
101103lappend ans3 [list set _LMFILES_ $modulefile]
102104lappend ans3 [list set LOADEDMODULES $module]
103105lappend ans3 [list alias ts2 {echo "http://an.example.web?¶m=one"}]
106+ lappend ans3 [list alias ts3 {echo "select[type==BAR && osrel==FOO]" myapp}]
104107lappend ans3 [list alias testsuite {echo (grep "report .Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}')}]
105108
106109
You can’t perform that action at this time.
0 commit comments