I'm running a GUI program called zeal(compiled from src) and add a script(zeal.sh) for the executable:
#!/bin/bash if pgrep zeal &>/dev/null; then printf "already on\n" else ~/tools/zeal/zeal/zeal &>/dev/null & fi The strange thing is that when I run this script like /path/to/zeal.sh, it always tells "already on", while with bash /path/to/zeal.sh it correctly decides whether the process is running or not.
I also checked other GUI programs(like firefox) with similar scripts and they work fine.
So how can this happen and how to fix it?