about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2024-04-13 23:24:43 -0500
committerCase Duckworth2024-04-13 23:24:43 -0500
commit8725f85012f5cf19ce8b25c75a0d5f6cf059978a (patch)
tree0d56fa7f60d9ed8798ec18b6153adc98229f7910
parentAdd COPYING and README (diff)
downloadok-8725f85012f5cf19ce8b25c75a0d5f6cf059978a.tar.gz
ok-8725f85012f5cf19ce8b25c75a0d5f6cf059978a.zip
Add 'ok -' which allows to do ok without death
-rwxr-xr-xok20
1 files changed, 16 insertions, 4 deletions
diff --git a/ok b/ok index 058c98d..22aa7bb 100755 --- a/ok +++ b/ok
@@ -2,6 +2,7 @@
2 2
3QUIET=false 3QUIET=false
4NORUN=false 4NORUN=false
5DIE=true
5FNEW=false 6FNEW=false
6_ARGS=true 7_ARGS=true
7 8
@@ -28,6 +29,12 @@ $(sed -n \
28EOH 29EOH
29} 30}
30 31
32die(){
33 ec="$1"; shift
34 printf '%s\n' "$*" >&2
35 exit $ec
36}
37
31procargs(){ 38procargs(){
32 $_ARGS || return 1 39 $_ARGS || return 1
33 while getopts hqnxBf:C: OPT 40 while getopts hqnxBf:C: OPT
@@ -52,7 +59,7 @@ go(){
52 test -z "$1" && "$DEFAULT" 59 test -z "$1" && "$DEFAULT"
53 for target 60 for target
54 do 61 do
55 if grep -q "$target" "$FRFILE" 62 if grep -q "$target" "$FRFILE" 2>/dev/null
56 then if buildp "$target" \ 63 then if buildp "$target" \
57 "$(grep "$target" "$FRFILE" | cut -f3-)" 64 "$(grep "$target" "$FRFILE" | cut -f3-)"
58 then eval "$(grep "$target" "$FRFILE" | cut -f2-)" 65 then eval "$(grep "$target" "$FRFILE" | cut -f2-)"
@@ -63,7 +70,7 @@ go(){
63} 70}
64 71
65dep(){ 72dep(){
66 _ARGS=false go "$@" 73 _ARGS=false go "$@" || exit "$((200 + $?))"
67} 74}
68 75
69buildp(){ # buildp TARGET DEPENDENCIES... 76buildp(){ # buildp TARGET DEPENDENCIES...
@@ -79,8 +86,13 @@ buildp(){ # buildp TARGET DEPENDENCIES...
79} 86}
80 87
81ok(){ # ok COMMAND ARGS.. 88ok(){ # ok COMMAND ARGS..
89 case "$1" in (-) DIE=false; shift ;; esac
82 $QUIET || printf >&2 '* %s\n' "$*" 90 $QUIET || printf >&2 '* %s\n' "$*"
83 $NORUN || "$@" || exit $((100 + $?)) 91 $NORUN || "$@"; ec="$?"
92 if $DIE && test $ec -ne 0
93 then die $((100 + $?)) not ok
94 else return $ec
95 fi
84} 96}
85 97
86quietly(){ "$@" >/dev/null 2>&1; } 98quietly(){ "$@" >/dev/null 2>&1; }
@@ -106,4 +118,4 @@ fr(){ # fr < TARGET JOB DEPS...
106 done 118 done
107} 119}
108 120
109go "$@" 121go "$@" && echo ok