Skip to content

Commit bc51f3e

Browse files
committed
Fix source-sh/sh-to-mod shell translation for Fish 4.0
Signed-off-by: Xavier Delaruelle <[email protected]>
1 parent 41c0fc0 commit bc51f3e

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

NEWS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Modules 5.6.0 (not yet released)
3636
* Doc: add :ref:`add-new-maintainer` guide
3737
* Fix interpreter variable reset between multiple modulefile or modulerc
3838
evaluations when variable initial value is an invalid list. (fix issue #570)
39+
* Fix :mfcmd:`source-sh` and :subcmd:`sh-to-mod` shell translation when used
40+
with new *fish* shell version (4.0).
3941

4042
.. _Security policy: https://github.com/envmodules/modules/blob/main/SECURITY.md
4143
.. _Modules chat room: https://matrix.to/#/#modules:matrix.org

tcl/mfcmd.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ proc execShAndGetEnv {elt_ignored_list shell script args} {
14861486
shell $shdesc] 2>&1; or exit \$status; echo '$sep'; set -xgL;\
14871487
echo '$sep'; $getfunc; string split \$funcout; echo '$sep';\
14881488
string split \$funcout; echo '$sep'; complete; echo '$sep'; pwd"
1489-
set varre {^(\S+?\M) ?'?(.*?)'?$}
1489+
set varre {^(\S+?\M) ?['"]?(.*?)['"]?$}
14901490
# exclude alias from function list
14911491
set funcre "^function (\\S+?)(?: \[^\\n\]*?--description\
14921492
(?!'?alias)\[^\\n\]+)?\\n(.+?)?\\s*\\nend\\n$subsep\$"

testsuite/modules.00-init/005-init_ts.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ if {[set fishbin [lindex [auto_execok fish] 0]] ne {}} {
102102
regexp {version (.+)$} [exec $fishbin --version] match fish_version
103103
set fish_version_ge31 [expr {[lindex [lsort -dictionary [list $fish_version 3.1.0]] 0] eq {3.1.0}}]
104104
set fish_version_ge32 [expr {[lindex [lsort -dictionary [list $fish_version 3.2.0]] 0] eq {3.2.0}}]
105+
set fish_version_ge40 [expr {[lindex [lsort -dictionary [list $fish_version 4.0.0]] 0] eq {4.0.0}}]
105106
}
106107

107108
# find ksh flavor

testsuite/modules.70-maint/310-sh-to-mod.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,15 @@ set tscomp_tcsh "complete\ttcsh cmd {'n/-h/n/' 'n/--help/n/' 'n/-V/n/' 'n/--vers
226226
complete\ttcsh mycmd {'n/help/`_module_avail`/' 'n/add/`_module_not_yet_loaded; echo \"--auto --no-auto --force -f --icase -i --tag --tag=\"`/'}
227227
complete\ttcsh othercmd 'n/--help/n/'"
228228
if {[info exists fish_version_ge31] && $fish_version_ge31} {
229+
if {[info exists fish_version_ge40] && $fish_version_ge40} {
230+
set tscomp_alias_fish "complete\tfish alcb --wraps\\ 'echo\\ f\\\\\\\\\\\{o'
231+
complete\tfish alfoo {--wraps 'echo (grep \"report .Modules \" ../../modulecmd.tcl | tr -d \\\\\\\\ 2>/dev/null | awk \\'{print \$3}\\')'}
232+
complete\tfish alsp {--wraps 'echo f\\\\\"o; echo b\\\\\\\\\\\\\"r; echo f\\\\\\'o'}"
233+
} else {
229234
set tscomp_alias_fish "complete\tfish alcb {--wraps echo\\ f\\\\\\\{o}
230235
complete\tfish alfoo {--wraps echo\\ \\(grep\\ \\\"report\\ .Modules\\ \\\"\\ ../../modulecmd.tcl\\ \\|\\ tr\\ -d\\ \\\\\\\\\\ 2\\>/dev/null\\ \\|\\ awk\\ \\'\\{print\\ \\\$3\\}\\'\\)}
231236
complete\tfish alsp {--wraps echo\\ f\\\\\\\"o\\;\\ echo\\ b\\\\\\\\\\\\\\\"r\\;\\ echo\\ f\\\\\\'o}"
237+
}
232238
set tscomp_fish "complete\tfish cmd {-l help -d 'Command help'}
233239
complete\tfish cmd {-l version -d 'Command version'}
234240
complete\tfish cmd {-s h -d 'Command help'}

0 commit comments

Comments
 (0)