run: Fix shell scripting bugs

* Use double quotes around `"$@"` to fix invocation with arguments
  including spaces.
* Use double quotes around `"$(dirname "$0")"` to fix invocation
  inside a directory path including spaces.
* Use `set -e` to abort in case `cd` fails.
* Use `exec` to avoid forking an unnecessary wrapper process.
* Skip an unnecessary `cd` → `pwd` → `cd` dance, just use `cd`.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2019-08-17 11:25:29 -07:00
parent 654cbac77e
commit 5052f823d7
1 changed files with 3 additions and 6 deletions

9
run
View File

@ -1,7 +1,4 @@
#!/usr/bin/env sh
BASE_DIR="$(cd $(dirname "$0"); pwd)"
cd "$BASE_DIR"
python -m websockify $@
set -e
cd "$(dirname "$0")"
exec python -m websockify "$@"