mirror of
https://github.com/envmodules/modules.git
synced 2026-05-30 00:12:31 +08:00
Protect sh alias and function unset code
"unalias" command raises an error on "sh" kind shell when alias to unset is not defined. Shell code is added to drop this error message and always return success. Same methodology is applied when unsetting function on "sh" kind shell. An error is raised on "zsh" shell when function is not defined. Protection code is applied for all shell of the "sh" kind for simplicity.
This commit is contained in:
@@ -846,6 +846,7 @@ txt
|
||||
ubuntu
|
||||
umask
|
||||
un
|
||||
unalias
|
||||
uname
|
||||
uncomplete
|
||||
undef
|
||||
|
||||
4
NEWS.rst
4
NEWS.rst
@@ -116,6 +116,10 @@ Modules 5.4.0 (not yet released)
|
||||
sub-commands.
|
||||
* Lib: slightly adapt code of Modules Tcl extension library to properly build
|
||||
against Tcl 9.0.
|
||||
* Adapt alias unset shell code for *sh*-kind shells to avoid errors when alias
|
||||
to unset is not defined.
|
||||
* Adapt function unset shell code for *sh*-kind shells to avoid errors when
|
||||
function to unset is not defined.
|
||||
|
||||
|
||||
.. _5.3 release notes:
|
||||
|
||||
@@ -353,7 +353,7 @@ proc renderSettings {} {
|
||||
lappend g_shcode_out "unalias $var;"
|
||||
}
|
||||
sh {
|
||||
lappend g_shcode_out "unalias $var;"
|
||||
lappend g_shcode_out "unalias $var 2>/dev/null || true;"
|
||||
}
|
||||
fish {
|
||||
lappend g_shcode_out "functions -e $var;"
|
||||
@@ -386,7 +386,8 @@ proc renderSettings {} {
|
||||
del {
|
||||
switch -- [getState shelltype] {
|
||||
sh {
|
||||
lappend g_shcode_out "unset -f $funcname;"
|
||||
lappend g_shcode_out "unset -f $funcname 2>/dev/null ||\
|
||||
true;"
|
||||
}
|
||||
fish {
|
||||
lappend g_shcode_out "functions -e $funcname;"
|
||||
|
||||
Reference in New Issue
Block a user