helpers2.1: ynh_exec_warn_less -> ynh_hide_warnings

This commit is contained in:
Alexandre Aubin 2024-06-11 18:41:37 +02:00
parent a8cd94d3db
commit 66508d5fd6

View file

@ -52,15 +52,12 @@ ynh_print_warn() {
echo -e "${message}" >&2 echo -e "${message}" >&2
} }
# Execute a command and force the result to be printed on stdout # Execute a command and redirect stderr to stdout
# #
# usage: ynh_exec_warn_less your command and args # usage: ynh_hide_warnings your command and args
# | arg: command - command to execute # | arg: command - command to execute
# #
# Note that you should NOT quote the command but only prefix it with ynh_exec_warn ynh_hide_warnings() {
#
# Requires YunoHost version 3.2.0 or higher.
ynh_exec_warn_less() {
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077 # Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
"$@" 2>&1 "$@" 2>&1
} }
@ -79,7 +76,7 @@ ynh_exec_and_print_stderr_only_if_error() {
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077 # Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
"$@" 2> "$logfile" || rc="$?" "$@" 2> "$logfile" || rc="$?"
if (( rc != 0 )); then if (( rc != 0 )); then
ynh_exec_warn cat "$logfile" cat "$logfile" >&2
ynh_safe_rm "$logfile" ynh_safe_rm "$logfile"
return "$rc" return "$rc"
fi fi