How do I suppress GtkDialog warnings in zenity and yad using Bash redirection in a script?How to make zenity “transient parent” warning disappear permanentlybash script and zenity progressrun bash script from another script and redirect its outputPort redirection for a specific (dynamic) IP using iptables scriptHiding terminal when executing zenity bash script by double clickBuilding a dynamic zenity list using bash variableZenity and bashRandom script using bashHow to make zenity “transient parent” warning disappear permanentlyBash one-liner to display ALL `gsettings` in Zenity or YadHow to suppress warnings in gromacs?
Must a warlock replace spells with new spells of exactly their Pact Magic spell slot level?
How to cut a climbing rope?
Why do Russians almost not use verbs of possession akin to "have"?
Why does the hash of infinity have the digits of π?
Are runways booked by airlines to land their planes?
Why would a rational buyer offer to buy with no conditions precedent?
Time complexity of an algorithm: Is it important to state the base of the logarithm?
Did this character show any indication of wanting to rule before S8E6?
Is it legal to have an abortion in another state or abroad?
Popcorn is the only acceptable snack to consume while watching a movie
USPS Back Room - Trespassing?
Need to read my home electrical Meter
The art of clickbait captions
Why are GND pads often only connected by four traces?
Why A=2 and B=1 in the call signs for Spirit and Opportunity?
What is the meaning of "<&3" and "done < file11 3< file22"
Take elements from a list based on two criteria
If a (distance) metric on a connected Riemannian manifold locally agrees with the Riemannian metric, is it equal to the induced metric?
Are black holes spherical during merger?
What Armor Optimization applies to a Mithral full plate?
Function argument returning void or non-void type
Why are Stein manifolds/spaces the analog of affine varieties/schemes in algebraic geometry?
Why isn't 'chemically-strengthened glass' made with potassium carbonate to begin with?
What are the conditions for RAA?
How do I suppress GtkDialog warnings in zenity and yad using Bash redirection in a script?
How to make zenity “transient parent” warning disappear permanentlybash script and zenity progressrun bash script from another script and redirect its outputPort redirection for a specific (dynamic) IP using iptables scriptHiding terminal when executing zenity bash script by double clickBuilding a dynamic zenity list using bash variableZenity and bashRandom script using bashHow to make zenity “transient parent” warning disappear permanentlyBash one-liner to display ALL `gsettings` in Zenity or YadHow to suppress warnings in gromacs?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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:
- How to make zenity “transient parent” warning disappear permanently (using function)
and here:
- How to make zenity “transient parent” warning disappear permanently (using alias)
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?
command-line bash redirect
|
show 4 more comments
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:
- How to make zenity “transient parent” warning disappear permanently (using function)
and here:
- How to make zenity “transient parent” warning disappear permanently (using alias)
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?
command-line bash redirect
2
Can't you just redirect stderr for the duration of the script usingexec
? Something likeexec 2> >(grep -v GtkDialog >&2)
– steeldriver
May 17 at 17:16
@steeldriver you mean use that command on second line after the#!/bin/bash
?
– WinEunuuchs2Unix
May 17 at 17:21
anywhere before where you want to start filtering the stream - doesn't have to be right after the shebang
– steeldriver
May 17 at 17:24
steeldriver's suggestion is good and works in interactive shells as well. @steeldriver I would recommend making an answer out of that.
– Sergiy Kolodyazhnyy
May 17 at 17:32
Array may have to be unquoted for this to work
– Sergiy Kolodyazhnyy
May 17 at 17:33
|
show 4 more comments
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:
- How to make zenity “transient parent” warning disappear permanently (using function)
and here:
- How to make zenity “transient parent” warning disappear permanently (using alias)
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?
command-line bash redirect
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:
- How to make zenity “transient parent” warning disappear permanently (using function)
and here:
- How to make zenity “transient parent” warning disappear permanently (using alias)
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?
command-line bash redirect
command-line bash redirect
edited May 18 at 10:31
dessert
27.3k682115
27.3k682115
asked May 17 at 16:54
WinEunuuchs2UnixWinEunuuchs2Unix
50.8k12100195
50.8k12100195
2
Can't you just redirect stderr for the duration of the script usingexec
? Something likeexec 2> >(grep -v GtkDialog >&2)
– steeldriver
May 17 at 17:16
@steeldriver you mean use that command on second line after the#!/bin/bash
?
– WinEunuuchs2Unix
May 17 at 17:21
anywhere before where you want to start filtering the stream - doesn't have to be right after the shebang
– steeldriver
May 17 at 17:24
steeldriver's suggestion is good and works in interactive shells as well. @steeldriver I would recommend making an answer out of that.
– Sergiy Kolodyazhnyy
May 17 at 17:32
Array may have to be unquoted for this to work
– Sergiy Kolodyazhnyy
May 17 at 17:33
|
show 4 more comments
2
Can't you just redirect stderr for the duration of the script usingexec
? Something likeexec 2> >(grep -v GtkDialog >&2)
– steeldriver
May 17 at 17:16
@steeldriver you mean use that command on second line after the#!/bin/bash
?
– WinEunuuchs2Unix
May 17 at 17:21
anywhere before where you want to start filtering the stream - doesn't have to be right after the shebang
– steeldriver
May 17 at 17:24
steeldriver's suggestion is good and works in interactive shells as well. @steeldriver I would recommend making an answer out of that.
– Sergiy Kolodyazhnyy
May 17 at 17:32
Array may have to be unquoted for this to work
– Sergiy Kolodyazhnyy
May 17 at 17:33
2
2
Can't you just redirect stderr for the duration of the script using
exec
? Something like exec 2> >(grep -v GtkDialog >&2)
– steeldriver
May 17 at 17:16
Can't you just redirect stderr for the duration of the script using
exec
? Something like exec 2> >(grep -v GtkDialog >&2)
– steeldriver
May 17 at 17:16
@steeldriver you mean use that command on second line after the
#!/bin/bash
?– WinEunuuchs2Unix
May 17 at 17:21
@steeldriver you mean use that command on second line after the
#!/bin/bash
?– WinEunuuchs2Unix
May 17 at 17:21
anywhere before where you want to start filtering the stream - doesn't have to be right after the shebang
– steeldriver
May 17 at 17:24
anywhere before where you want to start filtering the stream - doesn't have to be right after the shebang
– steeldriver
May 17 at 17:24
steeldriver's suggestion is good and works in interactive shells as well. @steeldriver I would recommend making an answer out of that.
– Sergiy Kolodyazhnyy
May 17 at 17:32
steeldriver's suggestion is good and works in interactive shells as well. @steeldriver I would recommend making an answer out of that.
– Sergiy Kolodyazhnyy
May 17 at 17:32
Array may have to be unquoted for this to work
– Sergiy Kolodyazhnyy
May 17 at 17:33
Array may have to be unquoted for this to work
– Sergiy Kolodyazhnyy
May 17 at 17:33
|
show 4 more comments
3 Answers
3
active
oldest
votes
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:
$ arr=( ">" "/dev/null" )
$ set -x
$ echo foo "$arr[@]"
+ echo foo '>' /dev/null
foo > /dev/null
i.e. everything has been expanded "correctly", but > /dev/null
has simply become a list of string arguments passed to echo
.
You could force evaluation using eval
:
$ eval echo foo "$arr[@]"
+ eval echo foo '>' /dev/null
++ echo foo
but really it would be better to redirect the stream for the duration of your script using exec
:
exec 2> >(grep -v GtkDialog >&2)
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 do
exec 3>&2 2> >(grep -v GtkDialog >&2)
and then later
exec 2>&3 3>&-
to recover the duplicated stream.
1
I haven't tested everything butexec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before usingyad
works fine as far as I can tell.
– WinEunuuchs2Unix
May 17 at 18:41
add a comment |
You can use function in the script. zenity
and yad
have useful info in stdout, so I suggest to redirect just stderr to /dev/null
#/bin/bash
zen_nospam()
zenity "$@" 2&>1 >(grep -v GtkDialog >&2)
zen_nospam --error --text hello
btw function can be defined in .bashrc if needed in command line, not script
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
add a comment |
You can define and use aliases in your script if you set the expand_aliases
shell option, e.g.:
#!/bin/bash
shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
…
Now every zenity
line behaves as if 2> >(grep -v GtkDialog >&2)
were added and you can disable this behaviour as usual by prepending a backslash or command
:
zenity # and
command zenity
both ignore the alias.
Further reading
- Why doesn't my Bash script recognize aliases?
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to useshopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.
– WinEunuuchs2Unix
May 17 at 23:42
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1144080%2fhow-do-i-suppress-gtkdialog-warnings-in-zenity-and-yad-using-bash-redirection-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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:
$ arr=( ">" "/dev/null" )
$ set -x
$ echo foo "$arr[@]"
+ echo foo '>' /dev/null
foo > /dev/null
i.e. everything has been expanded "correctly", but > /dev/null
has simply become a list of string arguments passed to echo
.
You could force evaluation using eval
:
$ eval echo foo "$arr[@]"
+ eval echo foo '>' /dev/null
++ echo foo
but really it would be better to redirect the stream for the duration of your script using exec
:
exec 2> >(grep -v GtkDialog >&2)
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 do
exec 3>&2 2> >(grep -v GtkDialog >&2)
and then later
exec 2>&3 3>&-
to recover the duplicated stream.
1
I haven't tested everything butexec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before usingyad
works fine as far as I can tell.
– WinEunuuchs2Unix
May 17 at 18:41
add a comment |
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:
$ arr=( ">" "/dev/null" )
$ set -x
$ echo foo "$arr[@]"
+ echo foo '>' /dev/null
foo > /dev/null
i.e. everything has been expanded "correctly", but > /dev/null
has simply become a list of string arguments passed to echo
.
You could force evaluation using eval
:
$ eval echo foo "$arr[@]"
+ eval echo foo '>' /dev/null
++ echo foo
but really it would be better to redirect the stream for the duration of your script using exec
:
exec 2> >(grep -v GtkDialog >&2)
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 do
exec 3>&2 2> >(grep -v GtkDialog >&2)
and then later
exec 2>&3 3>&-
to recover the duplicated stream.
1
I haven't tested everything butexec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before usingyad
works fine as far as I can tell.
– WinEunuuchs2Unix
May 17 at 18:41
add a comment |
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:
$ arr=( ">" "/dev/null" )
$ set -x
$ echo foo "$arr[@]"
+ echo foo '>' /dev/null
foo > /dev/null
i.e. everything has been expanded "correctly", but > /dev/null
has simply become a list of string arguments passed to echo
.
You could force evaluation using eval
:
$ eval echo foo "$arr[@]"
+ eval echo foo '>' /dev/null
++ echo foo
but really it would be better to redirect the stream for the duration of your script using exec
:
exec 2> >(grep -v GtkDialog >&2)
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 do
exec 3>&2 2> >(grep -v GtkDialog >&2)
and then later
exec 2>&3 3>&-
to recover the duplicated stream.
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:
$ arr=( ">" "/dev/null" )
$ set -x
$ echo foo "$arr[@]"
+ echo foo '>' /dev/null
foo > /dev/null
i.e. everything has been expanded "correctly", but > /dev/null
has simply become a list of string arguments passed to echo
.
You could force evaluation using eval
:
$ eval echo foo "$arr[@]"
+ eval echo foo '>' /dev/null
++ echo foo
but really it would be better to redirect the stream for the duration of your script using exec
:
exec 2> >(grep -v GtkDialog >&2)
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 do
exec 3>&2 2> >(grep -v GtkDialog >&2)
and then later
exec 2>&3 3>&-
to recover the duplicated stream.
answered May 17 at 18:00
steeldriversteeldriver
73k11119194
73k11119194
1
I haven't tested everything butexec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before usingyad
works fine as far as I can tell.
– WinEunuuchs2Unix
May 17 at 18:41
add a comment |
1
I haven't tested everything butexec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before usingyad
works fine as far as I can tell.
– WinEunuuchs2Unix
May 17 at 18:41
1
1
I haven't tested everything but
exec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before using yad
works fine as far as I can tell.– WinEunuuchs2Unix
May 17 at 18:41
I haven't tested everything but
exec 2> >(grep -v 'GtkDialog mapped without a transient parent' >&2)
in script before using yad
works fine as far as I can tell.– WinEunuuchs2Unix
May 17 at 18:41
add a comment |
You can use function in the script. zenity
and yad
have useful info in stdout, so I suggest to redirect just stderr to /dev/null
#/bin/bash
zen_nospam()
zenity "$@" 2&>1 >(grep -v GtkDialog >&2)
zen_nospam --error --text hello
btw function can be defined in .bashrc if needed in command line, not script
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
add a comment |
You can use function in the script. zenity
and yad
have useful info in stdout, so I suggest to redirect just stderr to /dev/null
#/bin/bash
zen_nospam()
zenity "$@" 2&>1 >(grep -v GtkDialog >&2)
zen_nospam --error --text hello
btw function can be defined in .bashrc if needed in command line, not script
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
add a comment |
You can use function in the script. zenity
and yad
have useful info in stdout, so I suggest to redirect just stderr to /dev/null
#/bin/bash
zen_nospam()
zenity "$@" 2&>1 >(grep -v GtkDialog >&2)
zen_nospam --error --text hello
btw function can be defined in .bashrc if needed in command line, not script
You can use function in the script. zenity
and yad
have useful info in stdout, so I suggest to redirect just stderr to /dev/null
#/bin/bash
zen_nospam()
zenity "$@" 2&>1 >(grep -v GtkDialog >&2)
zen_nospam --error --text hello
btw function can be defined in .bashrc if needed in command line, not script
edited May 17 at 17:31
answered May 17 at 17:22
LeonidMewLeonidMew
1,7641127
1,7641127
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
add a comment |
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
Your answer is sort of where I started from: askubuntu.com/a/1110850/307523 and askubuntu.com/a/896940/307523
– WinEunuuchs2Unix
May 17 at 17:26
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@WinEunuuchs2Unix Please add all this information to your question!
– dessert
May 17 at 18:41
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
@dessert I added this to question introduction but perhaps it could be worded better.
– WinEunuuchs2Unix
May 17 at 19:30
add a comment |
You can define and use aliases in your script if you set the expand_aliases
shell option, e.g.:
#!/bin/bash
shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
…
Now every zenity
line behaves as if 2> >(grep -v GtkDialog >&2)
were added and you can disable this behaviour as usual by prepending a backslash or command
:
zenity # and
command zenity
both ignore the alias.
Further reading
- Why doesn't my Bash script recognize aliases?
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to useshopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.
– WinEunuuchs2Unix
May 17 at 23:42
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
add a comment |
You can define and use aliases in your script if you set the expand_aliases
shell option, e.g.:
#!/bin/bash
shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
…
Now every zenity
line behaves as if 2> >(grep -v GtkDialog >&2)
were added and you can disable this behaviour as usual by prepending a backslash or command
:
zenity # and
command zenity
both ignore the alias.
Further reading
- Why doesn't my Bash script recognize aliases?
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to useshopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.
– WinEunuuchs2Unix
May 17 at 23:42
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
add a comment |
You can define and use aliases in your script if you set the expand_aliases
shell option, e.g.:
#!/bin/bash
shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
…
Now every zenity
line behaves as if 2> >(grep -v GtkDialog >&2)
were added and you can disable this behaviour as usual by prepending a backslash or command
:
zenity # and
command zenity
both ignore the alias.
Further reading
- Why doesn't my Bash script recognize aliases?
You can define and use aliases in your script if you set the expand_aliases
shell option, e.g.:
#!/bin/bash
shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
…
Now every zenity
line behaves as if 2> >(grep -v GtkDialog >&2)
were added and you can disable this behaviour as usual by prepending a backslash or command
:
zenity # and
command zenity
both ignore the alias.
Further reading
- Why doesn't my Bash script recognize aliases?
answered May 17 at 19:55
dessertdessert
27.3k682115
27.3k682115
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to useshopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.
– WinEunuuchs2Unix
May 17 at 23:42
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
add a comment |
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to useshopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.
– WinEunuuchs2Unix
May 17 at 23:42
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to use
shopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.– WinEunuuchs2Unix
May 17 at 23:42
Although upvoting your answer I'm still using SteelDriver's answer for the time-being. Your answer did inspire me to use
shopt -u expand_aliases
so aliases cannot create unstable environment for my script. In other words, turn off all the user's aliases so the script doesn't behave erratically.– WinEunuuchs2Unix
May 17 at 23:42
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
@WinEunuuchs2Unix That’s not necessary, as “Aliases are not expanded when the shell is not interactive” – if you didn’t set the option before in your script it’s no use.
– dessert
May 18 at 7:17
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1144080%2fhow-do-i-suppress-gtkdialog-warnings-in-zenity-and-yad-using-bash-redirection-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Can't you just redirect stderr for the duration of the script using
exec
? Something likeexec 2> >(grep -v GtkDialog >&2)
– steeldriver
May 17 at 17:16
@steeldriver you mean use that command on second line after the
#!/bin/bash
?– WinEunuuchs2Unix
May 17 at 17:21
anywhere before where you want to start filtering the stream - doesn't have to be right after the shebang
– steeldriver
May 17 at 17:24
steeldriver's suggestion is good and works in interactive shells as well. @steeldriver I would recommend making an answer out of that.
– Sergiy Kolodyazhnyy
May 17 at 17:32
Array may have to be unquoted for this to work
– Sergiy Kolodyazhnyy
May 17 at 17:33