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

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.
Thank you! This was exactly what I needed. I tried solutions #` and #2 (independently). Both resolved the issue.

I DEFINITELY agree that better debugging would be helpful. I thought the X-KeepTerminal=true flag was supposed to keep the window open, but apparently not. No need to worry ... this time ... now that the issue is resolved.

Statistics: Posted by DadHavingFun — Tue Feb 10, 2026 1:07 am



Viewing all articles
Browse latest Browse all 8621

Trending Articles