Introduces kickstart.suppress_error function

This commit is contained in:
Bruno Tavares 2015-09-30 08:37:53 -03:00
parent 6538dd4bde
commit 38ad846aeb
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# kickstart.suppress_error command to run
Run the command with stder outputing to /dev/null.
Inform it is about to run.
When debug flag is enable, does not redirect stderr to help debugging.
Returns the command result.
### Example
```bash
$ kickstart.suppress_error dpkg -s pkg-that-does-not-exist | grep 'Status:'
Running "dpkg -s pkg-that-does-not-exist"
```
If there was an error executing `dpkg`, it will not show up on the console unless the debugg flag is enabled.

View File

@ -22,6 +22,16 @@ kickstart.mute() {
return $?
}
kickstart.suppress_error() {
kickstart.info "Running \"$*\""
if kickstart.debugging; then
"$@"
else
"$@" 2>/dev/null
fi
return $?
}
kickstart.command_exists() {
kickstart.mute which "$1"
}