Unmute muted commands on debugging

This commit is contained in:
Bruno Tavares 2014-03-05 07:51:16 -03:00
parent cafc7b1d93
commit 44169e4f86
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,20 @@
# kickstart.debugging
Returns 0 if you are debugging, and 1 if not
### Example
```bash
$ kickstart.debugging || echo nope
nope
$ set -x; kickstart.debugging && echo yup; set +x;
+ kickstart.debugging
+ grep xtrace
+ kickstart.stream.contains on
+ grep -q on
+ set -o
+ echo yup
yup
+ set +x
```

View File

@ -8,9 +8,17 @@ kickstart.context() {
kickstart_context="$@"
}
kickstart.debugging() {
set -o | grep xtrace | kickstart.stream.contains on
}
kickstart.mute() {
kickstart.info "Running \"$@\""
`"$@" >/dev/null 2>&1`
if kickstart.debugging; then
"$@"
else
`"$@" >/dev/null 2>&1`
fi
return $?
}