5

I have this script (among others) that generates my wallpaper upon every login/midnight. It has 755 permissions. Part of code:

#/bin/bash

convert -size 1440x900 xc:none wall.png
composite -gravity center ../pics/im256.png wall.png wall.png
composite -geometry 118x67+661+578 ../pics/im-title-white.png wall.png wall.png

TIME=`$HOME/bin/time.py | grep "\."`

if [[ $TIME == *\'* ]]
then
    # <...1...>
else
    # <...2...>
fi

I'm interested if my $TIME variable has ' symbols in it. When there are no ' symbols - everything is good.

Now when I know there is at least one ' symbol (or I can force make that way), when I double-click the script I find myself in else statement, when I run the script in terminal - I find myself in then statement. I would like to always get to then statement, but how?

I cropped the part that is failing (left - correct, right - wrong):

correct image wrong picture

1
  • 2
    I'm upvoting and voting-to-close at the same time, because actually it's a valid and complete question, with a helpful title. It's just that the issue was very minor. Nevertheless, it's a nice reminder that shell and graphical environments really invoke the scripts in a bit different way. Commented Dec 16, 2014 at 11:16

1 Answer 1

3

It took me to write a post until I notice that shebang is not actually a shebang. #!/bin/bash fixed the problem.

It appears that incorrect shebang defaulted to /bin/sh which was incapable of running correctly. My login shell is /bin/bash which means running from shell even without bash keyword eg.: ./script.sh defaults to bash and not sh. Why couldn't it do the same on double-click..

Sign up to request clarification or add additional context in comments.

3 Comments

Elaborate your answer, and accept it if it solved the problem.
Tried it: "You can accept your own answer in 2 days"
Oh, you are right. :) You should still add some clear-up to your answer, pointing out what the problem / mistake was, so others can learn from it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.