AllTheMods / Server-Scripts

Server Startup Scripts
Other
68 stars 37 forks source link

Script fails if ran directly with bash #49

Open Lartza opened 5 years ago

Lartza commented 5 years ago

bash ServerStart.sh fails on cd because it tries to cd to the filename

ServerStart.sh: line 143: cd: ServerStart.sh: Not a directory

Safest fix would seem to be to use cd "$(dirname "$(readlink -f "$0" || realpath "$0")")" || exit instead, from https://stackoverflow.com/a/17744637

LuizLoyola commented 4 years ago

Safest fix would seem to be to use cd "$(dirname "$(readlink -f "$0" || realpath "$0")")" || exit

This works. Can confirm on Debian 9.

matthew-williams commented 4 years ago

Run as sh ./ServerStart.sh This is a shell script, not a bash script.

Lartza commented 4 years ago

@matthew-williams https://github.com/AllTheMods/Server-Scripts/blob/master/ServerStart.sh#L1