Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8093

Troubleshooting • Re: .sh script behaving different in terminal than when called from *.desktop icon

$
0
0
Just a guess, but this looks like a "sh vs. bash" thing.

Often, you run into the situation where if your script doesn't have a #! line, then it gets executed with /bin/sh, which is reasonable, but won't work if your script has any "bash-isms". Note that it works OK if run from the bash prompt b/c then it gets the bash treatment, but when run outside of bash (e.g., by whatever mechanism "desktop icons" get run), then it defaults to /bin/sh.

So, ...

1) Quick solution: change "source" to "."
(bash recognizes "source" as a synonym for ".", but /bin/sh (i.e., dash) does not)

2) Less quick solution: Put #!/bin/bash
as the first line of the script.

3) Or, put #!/bin/sh as the first line and change "source" to "/"

Finally, in the long run, one will need to figure out how to debug these sorts of things, so that you can capture what is going on - beyond just "the terminal flashes". I think there is some option in the thing that edits the "desktop icon" thingie that says "Keep the window open" or something like that.

Statistics: Posted by BigRedMailbox — Mon Feb 09, 2026 8:51 am



Viewing all articles
Browse latest Browse all 8093

Trending Articles