1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +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:
V 2024-02-29 00:18:40 +01:00 committed by Robert Helgesson
parent bfc438e9b7
commit b3a9fb9d05
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
4 changed files with 19 additions and 3 deletions

View file

@ -99,16 +99,26 @@ function _iVerbose() {
# Runs the given command on live run, otherwise prints the command to standard
# 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
# error output is sent to `/dev/null` on a live run.
#
# The `--silence` and `--quiet` flags are mutually exclusive.
function run() {
if [[ $1 == '--silence' ]]; then
if [[ $1 == '--quiet' ]]; then
local quiet=1
shift
elif [[ $1 == '--silence' ]]; then
local silence=1
shift
fi
if [[ -v DRY_RUN ]] ; then
echo "$@"
elif [[ -v quiet ]] ; then
"$@" > /dev/null
elif [[ -v silence ]] ; then
"$@" > /dev/null 2>&1
else