File: sh-to-mod.fish

package info (click to toggle)
modules 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,493; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (137 lines) | stat: -rw-r--r-- 4,035 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# example shell script to test 'sh-to-mod' sub-command

if set -q TESTSUITE_SHTOMOD_SHELLVAR
   set -xg FOOSHELL $SHELL
end

if not set -q TESTSUITE_SHTOMOD_NOVAR
   set -xg FOO value
   set -xg FOOEM ""
   set -xg FOOSP "value "
   set -xg FOOCB va\{ue
   set -xg FOOWC va\*ue
   if test (count $argv) -gt 0
      for i in (seq (count $argv))
         set -xg FOOARG$i $argv[$i]
      end
   end
end

if not set -q TESTSUITE_SHTOMOD_NOPATH
   set -xg FOOPATH /path/to/dir1 /path/to/dir2 /path/to/dir3
   set -xg FOOPATHEM '' /path/to/dir1 /path/to/dir2 /path/to/dir3
   set -xg FOOPATHSP "/path/to/dir1 /path/to/dir2 /path/to/dir3"
   set -xg FOOPATHSPEM "/path/to/dir1 /path/to/dir2 /path/to/dir3 "
   set -xg FOOPATHCB /path/to/dir1 /path/to/d\{r2 /path/to/dir3
   set -xg FOOPATHWC /path/to/dir1 /path/to/d\*r2 /path/to/dir3
end

if set -q TESTSUITE_SHTOMOD_PATHDUP
   set -xg FOOPATHDUP "/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1:/path/to/dir3:/path/to dir4:/path/to/dir3"
   set -xg FOOPATHDUPEM :/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1:/path/to/dir3::/path/to/dir3
   set -xg FOOPATHDUPSP "/path/to/dir1 /path/to/dir1 /path/to/dir2 /path/to/dir1 /path/to/dir3 /path/to:dir4 /path/to/dir3"
   set -xg FOOPATHDUPSPEM "/path/to/dir1 /path/to/dir1 /path/to/dir2 /path/to/dir1 /path/to/dir3 /path/to/dir3 "
   set -xg FOOPATHDUPMIX ":/path/to/dir1:/path/to/dir1 /path/to/dir2 /path/to/dir1:/path/to/dir3:/path/to/dir3:"
end

if set -q TESTSUITE_SHTOMOD_FUZZYOUT1
   echo '%ModulesShToMod%'
end
if set -q TESTSUITE_SHTOMOD_FUZZYOUT2
   function echo
      true
   end
end

if not set -q TESTSUITE_SHTOMOD_NOALIAS
   alias alfoo='echo (grep "report .Modules " ../../modulecmd.tcl | tr -d \\\\ 2>/dev/null | awk \'{print $3}\')'
   alias alcb='echo f\{o'
   # alias with empty body cannot be set on fish shell
   #alias alem=''
   alias alsp="echo f\\\"o; echo b\\\\\\\"r; echo f\'o"
end

if not set -q TESTSUITE_SHTOMOD_NOFUNC
   function funcfoo
      echo foo
   end
   function funcnl
      echo foo
      echo bar
   end
   function funccb
      echo f\{o
   end
   function funcsp
      echo f\"o
      echo b\\\"r
      echo f\'o
   end
   function funcwc
      echo sou*sh
   end
   function func_nested
      function func_in
         echo foo
      end
      func_in
   end
end

if not set -q TESTSUITE_SHTOMOD_NOCOMP
   complete -c cmd -s V -l version --description 'Command version'
   complete --command cmd -s h -l help --description 'Command help'
   complete --no-files --require-parameter -c mycmd -s h --description 'Command help'
   # test complete definition without -c/--complete opt arg on fish>=3.2
   if test (string sub -s 1 -l 1 $version) -ge 3; and test (string sub -s 3 -l 1 $version) -ge 2
      complete -f othercmd -s h -l help --description 'Command help'
      complete othercmd -s V -l version --description 'Command version'
   else
      complete -f --command othercmd -s h -l help --description 'Command help'
      complete -c othercmd -s V -l version --description 'Command version'
   end
end

if not set -q TESTSUITE_SHTOMOD_NOCD
   cd $TESTSUITEDIR/modulefiles.2
end

if set -q TESTSUITE_SHTOMOD_OUTMSG
   echo "output message"
end

if set -q TESTSUITE_SHTOMOD_ERRMSG
   echo "error message" >&2
end

if set -q TESTSUITE_SHTOMOD_EXIT1
   exit 1
end

if set -q TESTSUITE_SHTOMOD_UNSETENV
   set -e TESTSUITE_SHTOMOD_UNSETENV
end

if set -q TESTSUITE_SHTOMOD_EMPTYAPPEND
   set -xg TESTSUITE_SHTOMOD_EMPTYAPPEND $TESTSUITE_SHTOMOD_EMPTYAPPEND:
end

if set -q TESTSUITE_SHTOMOD_EMPTYPREPEND
   set -xg TESTSUITE_SHTOMOD_EMPTYPREPEND :$TESTSUITE_SHTOMOD_EMPTYPREPEND
end

if set -q TESTSUITE_SHTOMOD_MODULE
   eval $TCLSH $MODULES_CMD fish autoinit | source -
   module config collection_target bar
   module load setenv/1.0
   functions -e ml module _module_raw mogui
   set -e MODULESHOME
end

if set -q TESTSUITE_SHTOMOD_UNSETALFUNCCOMP
   functions -e alfoo
   functions -e funcfoo
   complete -e -c cmd
end

# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: