I'm trying to suppress GtkDialog
warnings in zenity
and yad
:
$ zenity --error --text hello
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Error redirection and filtering works:
$ zenity --error --text hello 2> >(grep -v GtkDialog >&2)
YEAH… Annoying warning message disappears!!
This can be placed in ~/.bashrc
for development work as answered here:
and here:
When creating a script for others to use though, you don't want the burden of them changing their ~/.bashrc
.
I'm having trouble creating a typing shortcut for: 2> >(grep -v GtkDialog >&2)
to be used inside script.
For many reasons variable assignment GTK_SPAM="2> >(grep -v GtkDialog >&2)"
followed later by variable usage "$GTK_SPAM"
doesn't work.
alias zenity="zenity 2> >(grep -v GtkDialog >&2)"
before calling script works but, I can't use this within a script.
Using an array to hold the typing shortcut isn't working:
$ aGtkSpam=(2\> \>\(grep -v GtkDialog \>\&2\))
$ DumpArray "${aGtkSpam[@]}"
Array Elements:
0: 2>
1: >(grep
2: -v
3: GtkDialog
4: >&2)
$ zenity --error --text hello "${aGtkSpam[@]}"
This option is not available. Please see --help for all possible usages.
$ yad --text hello 2> >(grep -v GtkDialog >&2)
$ yad --text hello "${aGtkSpam[@]}"
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
I found many excellent generic answers on word-splitting and parameters which should solve my problem but a specific syntax eludes me.
Any clues?
Best Answer
I don't think syntax alone can help you here - because of the order in which the shell sets up redirections and expands variables. To give a very simple illustration:
i.e. everything has been expanded "correctly", but
> /dev/null
has simply become a list of string arguments passed toecho
.You could force evaluation using
eval
:but really it would be better to redirect the stream for the duration of your script using
exec
:or, if you want to be able to turn the filter off before the end of the script, then based on After using
exec 1>file
, how can I stop this redirection of the STDOUT to file and restore the normal operation of STDOUT? it should be possible to doand then later
to recover the duplicated stream.