mirror of
https://github.com/nix-community/home-manager
synced 2024-11-14 07:09:45 +01:00
treewide: stop run
from discarding error messages
In most cases where this function is used, suppressing only the standard output is more appropriate. Culling diagnostic output hides error messages and makes debugging more difficult and confusing. `$DRY_RUN_NULL`, which the `--silence` flag replaced, was used both for suppressing standard output on its own, and for doing so along with diagnostic output; however, when the `run` function was added this distinction was lost, and both outputs would be discarded. This reintroduces the needed functionality, and changes usages of `--silence` to `--quiet` where previously only standard output was suppressed, or where this should have probably been the case anyway. Change-Id: Ifb1b52a1d1eea0117261c782d686ad7c71b43162
This commit is contained in:
parent
507cd7a862
commit
e6a96733c5
4 changed files with 19 additions and 3 deletions
|
@ -99,16 +99,26 @@ function _iVerbose() {
|
||||||
# Runs the given command on live run, otherwise prints the command to standard
|
# Runs the given command on live run, otherwise prints the command to standard
|
||||||
# output.
|
# output.
|
||||||
#
|
#
|
||||||
|
# If given the command line option `--quiet`, then the command's standard output
|
||||||
|
# is sent to `/dev/null` on a live run.
|
||||||
|
#
|
||||||
# If given the command line option `--silence`, then the command's standard and
|
# If given the command line option `--silence`, then the command's standard and
|
||||||
# error output is sent to `/dev/null` on a live run.
|
# error output is sent to `/dev/null` on a live run.
|
||||||
|
#
|
||||||
|
# The `--silence` and `--quiet` flags are mutually exclusive.
|
||||||
function run() {
|
function run() {
|
||||||
if [[ $1 == '--silence' ]]; then
|
if [[ $1 == '--quiet' ]]; then
|
||||||
|
local quiet=1
|
||||||
|
shift
|
||||||
|
elif [[ $1 == '--silence' ]]; then
|
||||||
local silence=1
|
local silence=1
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -v DRY_RUN ]] ; then
|
if [[ -v DRY_RUN ]] ; then
|
||||||
echo "$@"
|
echo "$@"
|
||||||
|
elif [[ -v quiet ]] ; then
|
||||||
|
"$@" > /dev/null
|
||||||
elif [[ -v silence ]] ; then
|
elif [[ -v silence ]] ; then
|
||||||
"$@" > /dev/null 2>&1
|
"$@" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
|
|
|
@ -274,7 +274,7 @@ in
|
||||||
run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"
|
run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run --silence nix-store --realise "$newGenPath" --add-root "$newGenGcPath"
|
run --quiet nix-store --realise "$newGenPath" --add-root "$newGenGcPath"
|
||||||
if [[ -e "$legacyGenGcPath" ]]; then
|
if [[ -e "$legacyGenGcPath" ]]; then
|
||||||
run rm $VERBOSE_ARG "$legacyGenGcPath"
|
run rm $VERBOSE_ARG "$legacyGenGcPath"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -405,11 +405,17 @@ in
|
||||||
: Runs the given command on live run, otherwise prints the command to
|
: Runs the given command on live run, otherwise prints the command to
|
||||||
standard output.
|
standard output.
|
||||||
|
|
||||||
|
{command}`run --quiet {command}`
|
||||||
|
: Runs the given command on live run and sends its standard output to
|
||||||
|
{file}`/dev/null`, otherwise prints the command to standard output.
|
||||||
|
|
||||||
{command}`run --silence {command}`
|
{command}`run --silence {command}`
|
||||||
: Runs the given command on live run and sends its standard and error
|
: Runs the given command on live run and sends its standard and error
|
||||||
output to {file}`/dev/null`, otherwise prints the command to standard
|
output to {file}`/dev/null`, otherwise prints the command to standard
|
||||||
output.
|
output.
|
||||||
|
|
||||||
|
The `--quiet` and `--silence` flags are mutually exclusive.
|
||||||
|
|
||||||
A script block should also respect the {var}`VERBOSE` variable, and if
|
A script block should also respect the {var}`VERBOSE` variable, and if
|
||||||
set print information on standard out that may be useful for debugging
|
set print information on standard out that may be useful for debugging
|
||||||
any issue that may arise. The variable {var}`VERBOSE_ARG` is set to
|
any issue that may arise. The variable {var}`VERBOSE_ARG` is set to
|
||||||
|
|
|
@ -115,7 +115,7 @@ function nixProfileRemove() {
|
||||||
nixProfileList "$1" | xargs -rt $DRY_RUN_CMD nix profile remove $VERBOSE_ARG
|
nixProfileList "$1" | xargs -rt $DRY_RUN_CMD nix profile remove $VERBOSE_ARG
|
||||||
else
|
else
|
||||||
if nix-env -q | grep -q "^$1$"; then
|
if nix-env -q | grep -q "^$1$"; then
|
||||||
run --silence nix-env -e "$1"
|
run --quiet nix-env -e "$1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue