Fix escaping of '?' character in shell alias

Fixes #275.
This commit is contained in:
Xavier Delaruelle
2019-05-15 06:37:07 +02:00
parent 03fd7ea46e
commit 68b9eddaf1
5 changed files with 9 additions and 4 deletions

View File

@@ -5749,11 +5749,11 @@ proc resolveModuleVersionOrAlias {name} {
return $ret
}
proc charEscaped {str {charlist { \\\t\{\}|<>!;#^$&*"'`()}}} {
proc charEscaped {str {charlist { \\\t\{\}|<>!;#^$&*?"'`()}}} {
return [regsub -all "\(\[$charlist\]\)" $str {\\\1}]
}
proc charUnescaped {str {charlist { \\\t\{\}|<>!;#^$&*"'`()}}} {
proc charUnescaped {str {charlist { \\\t\{\}|<>!;#^$&*?"'`()}}} {
return [regsub -all "\\\\\(\[$charlist\]\)" $str {\1}]
}

View File

@@ -44,7 +44,7 @@ foreach shell $shell_list {
# ensure tools used in complex shell alias definition are available
if {[find_bin grep] ne "" && [find_bin tr] ne "" && [find_bin awk] ne ""} {
foreach shell $shell_list {
testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite" "Release" ".*" 0
testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2" "Release\nhttp://an.example.web\\?&param=one" ".*" 0
}
} elseif {$verbose > 0} {
send_user "\tSkipping shell alias definition tests\n"

View File

@@ -33,3 +33,5 @@ switch -- [module-info shelltype] {
}
}
# check '?' and '&' are correctly escaped
set-alias ts2 {echo "http://an.example.web?&param=one"}

View File

@@ -219,7 +219,7 @@ proc shell_val {test_shell val {re_mode 0}} {
if {$val ne "(.*)"} {
switch -- $test_shell {
{sh} - {bash} - {ksh} - {zsh} - {csh} - {tcsh} - {fish} {
set val [regsub -all {([\\"'$|{}`* ()!&])} $val {\\\1}]
set val [regsub -all {([\\"'$|{}`*? ()!&])} $val {\\\1}]
}
{lisp} - {cmake} {
set val [regsub -all {(["])} $val {\\\1}]

View File

@@ -76,16 +76,19 @@ set modulefile "$modpath/$module"
set ans [list]
lappend ans [list alias testsuite {echo $(grep "report .Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}')}]
lappend ans [list alias ts2 {echo "http://an.example.web?&param=one"}]
lappend ans [list setpath LOADEDMODULES $module]
lappend ans [list setpath _LMFILES_ $modulefile]
set ans2 [list]
lappend ans2 [list alias testsuite {echo `grep "report .Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}'`}]
lappend ans2 [list alias ts2 {echo "http://an.example.web?&param=one"}]
lappend ans2 [list setpath LOADEDMODULES $module]
lappend ans2 [list setpath _LMFILES_ $modulefile]
set ans3 [list]
lappend ans3 [list alias testsuite {echo (grep "report .Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}')}]
lappend ans3 [list alias ts2 {echo "http://an.example.web?&param=one"}]
lappend ans3 [list setpath LOADEDMODULES $module]
lappend ans3 [list setpath _LMFILES_ $modulefile]