From 590e7bb23dc15ec32272363b5eb10bc3aabe0294 Mon Sep 17 00:00:00 2001 From: Jacob Greenfield Date: Wed, 6 Mar 2019 11:35:35 -0500 Subject: [PATCH] Fix path quoting bug introduced in #220 (#227) It seems that some variables were mistakenly left unquoted, leading to paths containing spaces being treated incorrectly. For example, the directory `/home/person/foo bar/test/` would cause `CURDIR=$(pwd)` to be expanded to `CURDIR=/home/person/foo bar/test/`. This means that the shell would attempt to run the command `bar/test/` with the environment variable `CURDIR` set to `/home/person/foo`. This is due to [word splitting](https://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html). (TL;DR the result of shell expansions should probably be quoted 99% of the time) --- emsdk_env.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emsdk_env.sh b/emsdk_env.sh index fc96a18..df11073 100755 --- a/emsdk_env.sh +++ b/emsdk_env.sh @@ -19,11 +19,11 @@ SRC="$BASH_SOURCE" if [ "$SRC" = "" ]; then SRC="$0" fi -CURDIR=$(pwd) -cd $(dirname "$SRC") +CURDIR="$(pwd)" +cd "$(dirname "$SRC")" unset SRC ./emsdk construct_env "$@" . ./emsdk_set_env.sh -cd $CURDIR +cd "$CURDIR"