diff options
-rwxr-xr-x | ok | 20 |
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 | ||
3 | QUIET=false | 3 | QUIET=false |
4 | NORUN=false | 4 | NORUN=false |
5 | DIE=true | ||
5 | FNEW=false | 6 | FNEW=false |
6 | _ARGS=true | 7 | _ARGS=true |
7 | 8 | ||
@@ -28,6 +29,12 @@ $(sed -n \ | |||
28 | EOH | 29 | EOH |
29 | } | 30 | } |
30 | 31 | ||
32 | die(){ | ||
33 | ec="$1"; shift | ||
34 | printf '%s\n' "$*" >&2 | ||
35 | exit $ec | ||
36 | } | ||
37 | |||
31 | procargs(){ | 38 | procargs(){ |
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 | ||
65 | dep(){ | 72 | dep(){ |
66 | _ARGS=false go "$@" | 73 | _ARGS=false go "$@" || exit "$((200 + $?))" |
67 | } | 74 | } |
68 | 75 | ||
69 | buildp(){ # buildp TARGET DEPENDENCIES... | 76 | buildp(){ # buildp TARGET DEPENDENCIES... |
@@ -79,8 +86,13 @@ buildp(){ # buildp TARGET DEPENDENCIES... | |||
79 | } | 86 | } |
80 | 87 | ||
81 | ok(){ # ok COMMAND ARGS.. | 88 | ok(){ # 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 | ||
86 | quietly(){ "$@" >/dev/null 2>&1; } | 98 | quietly(){ "$@" >/dev/null 2>&1; } |
@@ -106,4 +118,4 @@ fr(){ # fr < TARGET JOB DEPS... | |||
106 | done | 118 | done |
107 | } | 119 | } |
108 | 120 | ||
109 | go "$@" | 121 | go "$@" && echo ok |