How to dismiss debug messages?

# start
[ "${DBG:=0}" = "1" ] || { echo "Output muted by default to avoid performance impact. Can unmute with DBG=1." && exec &>/dev/null; }

The above line comes from an application launcher script. Is there a way to do the same with an env line?


Moderator edit: In the future, please use proper formatting: [HowTo] Post command output and file content as formatted text

Perhaps. Why don’t you tell us exactly what you seek to accomplish?

Have you tried
DBG=1 application-name

The above line mutes debug messages, the 0 option does that. I can launch the app from the binary without the script, but debug messages are all over the place (can see them via terminal). How do i do the launching via binary with env and not the script? If i open the script with env DBG=1 i can see debug messages again dropping the mute action, but when i do env DBG=0 directly with the binary - nothing is muted.

That does the opposite and unmutes everything.

In order to mute all terminal output, you would do something like… :arrow_down:

application 2>&1 > /dev/null
1 Like

What application does this script snippet come from?

Is the application from Manjaro repositories or AUR or from a third party source?

If this is from a third party source the launch script may not work on Manjaro

So did you try DBG=0 application-name?

In general to set an env variable for any command it’s NAME=value command.

I don’t understand the

2>&1 >

2>&1 means “send stderr (the “2”) into the same data stream as stdout (the “1”)”. The next > /dev/null means “send this data stream into /dev/null”.

In layman’s terms, any process in a UNIX system has at a bare minimum three data streams, i.e. input, output, and error messages. So error messages are separated from normal output.

The first construct above takes the error messages that the application produces and routes them into the standard output stream. The second construct above takes the resulting combined data stream and redirects it into the NULL device instead of sending it to the terminal.

More information below… :arrow_down:

Is this the same with application &>/dev/null?

Yes, more or less. The end result is the same, but the logic is somewhat different. With &> you are using a shorthand, just like in the difference between the following notations… :arrow_down:

if [ condition_is_true ]
then
   do_something
fi

… versus… :arrow_down:

[ condition_is_true ] && do_something
1 Like