-
Notifications
You must be signed in to change notification settings - Fork 2
/
ml
executable file
·49 lines (47 loc) · 1.08 KB
/
ml
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
#!/usr/bin/env bash
usage(){
app=$(basename $0)
[ $# -gt 0 ] && echo "$@"
echo -e "
OPTIONS:
-o use octave
-e execute cmd instead of file
USAGE:
$app file.m
$app -e \"command1; command2\"
$app -o file.m"
exit 1
}
iseval=0 # run file or eval code
opts="-nosplash -nodesktop -r" # 20211119 '-batch' might be better. and no need for try,...,end?
bin="matlab"
# N.B. octave doesn't need this wrapper -- it will normally just run file and exit
# but it will work like matlab and makes this wrapper easier
while [ $# -ge 1 ]; do
case $1 in
-o)
opts="--no-gui --eval"
bin="octave"
shift;;
-e)
iseval=1
shift;;
-oe|-eo)
iseval=1
opts="--no-gui --eval"
bin="octave"
shift;;
*)
break;;
esac
done
if [ $iseval -eq 1 ]; then
[ $# -le 0 ] && usage "no matlab code given"
run="$@"
else
[ $# -ne 1 ] && usage "no file given"
[ ! -r "$1" ] && echo "bad file '$1'!" >&2 && exit 1
run="run('$1')"
fi
$bin $opts "try, $run; catch e, disp(e); end; quit()"
# while size(findobj(f))>0; pause; end;