| 1 |
# example shell script to test 'sh-to-mod' sub-command |
| 2 |
|
| 3 |
if set -q TESTSUITE_SHTOMOD_SHELLVAR |
| 4 |
set -xg FOOSHELL $SHELL |
| 5 |
end |
| 6 |
|
| 7 |
if not set -q TESTSUITE_SHTOMOD_NOVAR |
| 8 |
set -xg FOO value |
| 9 |
set -xg FOOEM "" |
| 10 |
set -xg FOOSP "value " |
| 11 |
set -xg FOOCB va\{ue |
| 12 |
set -xg FOOWC va\*ue |
| 13 |
if test (count $argv) -gt 0 |
| 14 |
for i in (seq (count $argv)) |
| 15 |
set -xg FOOARG$i $argv[$i] |
| 16 |
end |
| 17 |
end |
| 18 |
end |
| 19 |
|
| 20 |
if not set -q TESTSUITE_SHTOMOD_NOPATH |
| 21 |
set -xg FOOPATH /path/to/dir1 /path/to/dir2 /path/to/dir3 |
| 22 |
set -xg FOOPATHEM '' /path/to/dir1 /path/to/dir2 /path/to/dir3 |
| 23 |
set -xg FOOPATHSP "/path/to/dir1 /path/to/dir2 /path/to/dir3" |
| 24 |
set -xg FOOPATHSPEM "/path/to/dir1 /path/to/dir2 /path/to/dir3 " |
| 25 |
set -xg FOOPATHCB /path/to/dir1 /path/to/d\{r2 /path/to/dir3 |
| 26 |
set -xg FOOPATHWC /path/to/dir1 /path/to/d\*r2 /path/to/dir3 |
| 27 |
end |
| 28 |
|
| 29 |
if set -q TESTSUITE_SHTOMOD_PATHDUP |
| 30 |
set -xg FOOPATHDUP "/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1:/path/to/dir3:/path/to dir4:/path/to/dir3" |
| 31 |
set -xg FOOPATHDUPEM :/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1:/path/to/dir3::/path/to/dir3 |
| 32 |
set -xg FOOPATHDUPSP "/path/to/dir1 /path/to/dir1 /path/to/dir2 /path/to/dir1 /path/to/dir3 /path/to:dir4 /path/to/dir3" |
| 33 |
set -xg FOOPATHDUPSPEM "/path/to/dir1 /path/to/dir1 /path/to/dir2 /path/to/dir1 /path/to/dir3 /path/to/dir3 " |
| 34 |
set -xg FOOPATHDUPMIX ":/path/to/dir1:/path/to/dir1 /path/to/dir2 /path/to/dir1:/path/to/dir3:/path/to/dir3:" |
| 35 |
end |
| 36 |
|
| 37 |
if set -q TESTSUITE_SHTOMOD_FUZZYOUT1 |
| 38 |
echo '%ModulesShToMod%' |
| 39 |
end |
| 40 |
if set -q TESTSUITE_SHTOMOD_FUZZYOUT2 |
| 41 |
function echo |
| 42 |
true |
| 43 |
end |
| 44 |
end |
| 45 |
|
| 46 |
if not set -q TESTSUITE_SHTOMOD_NOALIAS |
| 47 |
alias alfoo='echo (grep "report .Modules " ../../modulecmd.tcl | tr -d \\\\ 2>/dev/null | awk \'{print $3}\')' |
| 48 |
alias alcb='echo f\{o' |
| 49 |
# alias with empty body cannot be set on fish shell |
| 50 |
#alias alem='' |
| 51 |
alias alsp="echo f\\\"o; echo b\\\\\\\"r; echo f\'o" |
| 52 |
end |
| 53 |
|
| 54 |
if not set -q TESTSUITE_SHTOMOD_NOFUNC |
| 55 |
function funcfoo |
| 56 |
echo foo |
| 57 |
end |
| 58 |
function funcnl |
| 59 |
echo foo |
| 60 |
echo bar |
| 61 |
end |
| 62 |
function funccb |
| 63 |
echo f\{o |
| 64 |
end |
| 65 |
function funcsp |
| 66 |
echo f\"o |
| 67 |
echo b\\\"r |
| 68 |
echo f\'o |
| 69 |
end |
| 70 |
function funcwc |
| 71 |
echo sou*sh |
| 72 |
end |
| 73 |
function func_nested |
| 74 |
function func_in |
| 75 |
echo foo |
| 76 |
end |
| 77 |
func_in |
| 78 |
end |
| 79 |
end |
| 80 |
|
| 81 |
if not set -q TESTSUITE_SHTOMOD_NOCOMP |
| 82 |
complete -c cmd -s V -l version --description 'Command version' |
| 83 |
complete --command cmd -s h -l help --description 'Command help' |
| 84 |
complete --no-files --require-parameter -c mycmd -s h --description 'Command help' |
| 85 |
# test complete definition without -c/--complete opt arg on fish>=3.2 |
| 86 |
if test (string sub -s 1 -l 1 $version) -ge 3; and test (string sub -s 3 -l 1 $version) -ge 2 |
| 87 |
complete -f othercmd -s h -l help --description 'Command help' |
| 88 |
complete othercmd -s V -l version --description 'Command version' |
| 89 |
else |
| 90 |
complete -f --command othercmd -s h -l help --description 'Command help' |
| 91 |
complete -c othercmd -s V -l version --description 'Command version' |
| 92 |
end |
| 93 |
end |
| 94 |
|
| 95 |
if not set -q TESTSUITE_SHTOMOD_NOCD |
| 96 |
cd $TESTSUITEDIR/modulefiles.2 |
| 97 |
end |
| 98 |
|
| 99 |
if set -q TESTSUITE_SHTOMOD_OUTMSG |
| 100 |
echo "output message" |
| 101 |
end |
| 102 |
|
| 103 |
if set -q TESTSUITE_SHTOMOD_ERRMSG |
| 104 |
echo "error message" >&2 |
| 105 |
end |
| 106 |
|
| 107 |
if set -q TESTSUITE_SHTOMOD_EXIT1 |
| 108 |
exit 1 |
| 109 |
end |
| 110 |
|
| 111 |
if set -q TESTSUITE_SHTOMOD_UNSETENV |
| 112 |
set -e TESTSUITE_SHTOMOD_UNSETENV |
| 113 |
end |
| 114 |
|
| 115 |
if set -q TESTSUITE_SHTOMOD_EMPTYAPPEND |
| 116 |
set -xg TESTSUITE_SHTOMOD_EMPTYAPPEND $TESTSUITE_SHTOMOD_EMPTYAPPEND: |
| 117 |
end |
| 118 |
|
| 119 |
if set -q TESTSUITE_SHTOMOD_EMPTYPREPEND |
| 120 |
set -xg TESTSUITE_SHTOMOD_EMPTYPREPEND :$TESTSUITE_SHTOMOD_EMPTYPREPEND |
| 121 |
end |
| 122 |
|
| 123 |
if set -q TESTSUITE_SHTOMOD_MODULE |
| 124 |
eval $TCLSH $MODULES_CMD fish autoinit | source - |
| 125 |
module config collection_target bar |
| 126 |
module load setenv/1.0 |
| 127 |
functions -e ml module _module_raw mogui |
| 128 |
set -e MODULESHOME |
| 129 |
end |
| 130 |
|
| 131 |
if set -q TESTSUITE_SHTOMOD_UNSETALFUNCCOMP |
| 132 |
functions -e alfoo |
| 133 |
functions -e funcfoo |
| 134 |
complete -e -c cmd |
| 135 |
end |
| 136 |
|
| 137 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |