mirror of
https://github.com/PapirusDevelopmentTeam/papirus-folders.git
synced 2024-09-19 11:08:48 -04:00
Write messages to stdout instead of stderr
Write verbose messages to a separated file descriptor and then redirect to stdout to avoid messed output from a subshell.
This commit is contained in:
parent
a16556e957
commit
7ca8189c9a
2 changed files with 15 additions and 8 deletions
|
@ -33,7 +33,7 @@ cat <<- EOF
|
|||
EOF
|
||||
|
||||
_msg() {
|
||||
echo "=>" "$@" >&2
|
||||
echo "=>" "$@"
|
||||
}
|
||||
|
||||
_rm() {
|
||||
|
|
|
@ -26,30 +26,30 @@ readonly VERSION="1.5.0"
|
|||
readonly -a ARGS=("$@")
|
||||
|
||||
msg() {
|
||||
printf "%s: %b\n" "$PROGNAME" "$*" >&2
|
||||
printf "%s: %b\n" "$PROGNAME" "$*"
|
||||
}
|
||||
|
||||
verbose() {
|
||||
[ "$VERBOSE" -eq 1 ] || return 0
|
||||
msg "$@"
|
||||
[ -t 4 ] || return 0
|
||||
msg "$@" >&4
|
||||
}
|
||||
|
||||
err() {
|
||||
msg "Error:" "$@"
|
||||
msg "Error:" "$*" >&2
|
||||
}
|
||||
|
||||
_exit() {
|
||||
msg "$@" "Exiting ..."
|
||||
msg "$*" "Exiting ..."
|
||||
exit 0
|
||||
}
|
||||
|
||||
fatal() {
|
||||
err "$@"
|
||||
err "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat >&2 <<- EOF
|
||||
cat <<- EOF
|
||||
USAGE
|
||||
$ $PROGNAME [options] -t <theme> {-C --color} <color>
|
||||
$ $PROGNAME [options] -t <theme> {-D --default}
|
||||
|
@ -458,6 +458,13 @@ main() {
|
|||
|
||||
parse_args "${ARGS[@]}"
|
||||
|
||||
if [ "$VERBOSE" -eq "1" ]; then
|
||||
# open a file descriptor for verbose messages
|
||||
exec 4>&1
|
||||
# close the file descriptor before exiting
|
||||
trap 'exec 4>&-' EXIT HUP INT TERM
|
||||
fi
|
||||
|
||||
THEME_DIR="$(get_theme_dir)" \
|
||||
|| fatal "Fail to find '$THEME_NAME' icon theme."
|
||||
|
||||
|
|
Loading…
Reference in a new issue