From 5052f823d74241d099688c3a8ceb0de57541e968 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 17 Aug 2019 11:25:29 -0700 Subject: [PATCH] run: Fix shell scripting bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- run | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/run b/run index 3dfa63f..8078ce9 100755 --- a/run +++ b/run @@ -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 "$@"