-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.tcsh
More file actions
executable file
·46 lines (45 loc) · 1.25 KB
/
example.tcsh
File metadata and controls
executable file
·46 lines (45 loc) · 1.25 KB
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
#!/usr/bin/env tcsh
make || exit
set spec='flags: f,flag=-g=-h g=-h=-qwerty qwerty=-flag=-h=-g h,help; parameters: q,asdf u=defval nothing zzz,z,Z=someth; positionals: asdf test;'
set helpmsg='\
help = print this help message\
flag = a random flag\
g = i dunno, its nonsense\
qwerty = a keyboard layout\
asdf = q param\
u = something\
zzz = a bunch of zs\
'
# print out the raw output
echo raw output:
#echo "$spec:q" | ./clparser --help-msg "$helpmsg:q" -- $argv:q
#set vars=`echo $spec | ./clparser -- $argv[*]`
set vars=`echo $spec:q | ./clparser -e --help-msg $helpmsg:q -- $argv:q`
#set vars="`eval echo '$spec:q' | ./clparser -- $argv:q`"
set ec=$?
echo vars len: $#vars
printf '%s\n' "$vars:q"
if ( "$ec" != 0 ) then
echo exit code: $ec
exit $ec
endif
# actually run it and show results
echo variable results:
eval "$vars:q"
#eval `echo "$spec:q" | ./clparser -e --help-msg "$helpmsg:q" -- $argv:q`
$help && exit
echo f,flag = "$flag"
echo g = "$g"
echo qwerty = "$qwerty"
echo h,help = "$help"
echo q,asdf = "$asdf"
echo u = "$u"
echo nothing = "$nothing"
echo zzz,z,Z = "$Z"
echo positional params:
echo asdf = "$asdf"
echo test = "$test"
#printf 'positional args: %s\n' "$*"
printf 'positional args:'
printf " '%s'" $args:q
printf '\n'