Bash script other output when doubleclick vs. run in terminal

I have this script (among others) that generates my wallpaper every time I enter / midnight. It has 755 permissions. Code Part:

#/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 am wondering if there is $TIME << 22> in my variable. If there are no characters, then everything is fine.

Now that I know that there is at least one character ' (or I can make it do this), when I double-click on the script, I am in the else , when I run the script in the terminal - I am in the then expression. I would always refer to the then expression, but how?

I trimmed the loss of the part (left - right, right - wrong):

correct imagewrong picture

+5
source share
1 answer

I needed to write a message until I noticed that shebang was not really a shebang. #!/bin/bash fixed the problem.

It looks like the default shebang was /bin/sh , which was unable to work correctly. My login shell is /bin/bash , which means starting from the shell even without the bash keyword, for example: ./script.sh by default is bash, not sh. Why couldn't he do the same with a double click ..

+3
source

Source: https://habr.com/ru/post/1209217/


All Articles