Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #14353

Bash if statements fail under xfce launcher?

From Charlie Gibbs <cgibbs@kltpzyxm.invalid>
Newsgroups comp.os.linux.misc
Subject Bash if statements fail under xfce launcher?
Date 2015-04-06 18:35 +0000
Organization NewsGuy - Unlimited Usenet $23.95
Message-ID <mfujm30hc5@news4.newsguy.com> (permalink)

Show all headers | View raw


I've written a shell script that uses zenity to ask the user for
a parameter, so it can be run from an icon in Xfce rather than
the command line.  The if statements don't seem to be properly
evaluated when the script is run through the GUI, although the
script works properly when run from the command line.  Here's a
stripped-down example that illustrates the problem:

x=$(zenity --list --text="Select an option" --radiolist --height 250 \
  --column "" --column "Option" TRUE default FALSE test)
echo "zenity returned /$x/" >foo
if [ "$x" == "default" ]; then
    echo "Default option was selected" >>foo
elif [ "$x" == "test" ]; then
    echo "Test option was selected" >>foo
else
    echo "This should never happen!" >>foo
fi

When I run it from the command line and select "default", foo contains
zenity returned /default/
Default option was selected

When I run it from the command line and select "test", foo contains
zenity returned /test/
Test option was selected

I've created an icon on the desktop to launch the script.  When
I double-click the icon the selection box comes up, but whichever
selection I make, foo contains the selection followed by
This should never happen!

Zenity is setting $x to the desired value, but the if and elif
statements don't recognize it.  Why should the if statements fail
when run from the GUI, when they work when run from the command line?

I'm running Debian Jessie - here's the output of uname -a:

Linux dragon 3.14-2-amd64 #1 SMP Debian 3.14.13-2 (2014-07-24) x86_64 GNU/Linux

The properties for my icon run the script from my home directory, which is
also specified as the working directory.  The "Use startup notification"
and "Run in terminal" checkboxes are not checked.

Are there any gotchas that I have to watch out for?

-- 
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs)
\ /  I'm really at ac.dekanfrus if you read it the right way.
 X   Top-posted messages will probably be ignored.  See RFC1855.
/ \  HTML will DEFINITELY be ignored.  Join the ASCII ribbon campaign!

Back to comp.os.linux.misc | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Bash if statements fail under xfce launcher? Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2015-04-06 18:35 +0000
  Re: Bash if statements fail under xfce launcher? Richard Kettlewell <rjk@greenend.org.uk> - 2015-04-06 20:06 +0100
    Re: Bash if statements fail under xfce launcher? Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2015-04-06 23:19 +0000
      Re: Bash if statements fail under xfce launcher? Richard Kettlewell <rjk@greenend.org.uk> - 2015-04-07 09:08 +0100
  Re: Bash if statements fail under xfce launcher? dave.gma+news002@googlemail.com.invalid (Dave Sines) - 2015-04-06 20:20 +0100
    Re: Bash if statements fail under xfce launcher? Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2015-04-06 23:19 +0000

csiph-web