From 2f9f3c0c826cf1a5f7fc5333f30f1a74efa316bd Mon Sep 17 00:00:00 2001 From: richdex14 Date: Mon, 4 Sep 2017 12:20:00 -0600 Subject: [PATCH] Update setup-node-ubuntu.bash to use portable `$sudo_cmd` syntax --- setup-node-ubuntu.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setup-node-ubuntu.bash b/setup-node-ubuntu.bash index 753ce20..db3210d 100644 --- a/setup-node-ubuntu.bash +++ b/setup-node-ubuntu.bash @@ -1,5 +1,9 @@ #!/bin/bash +# Not every platform has or needs sudo, gotta save them O(1)s... +sudo_cmd="" +((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo" + set -e set -u set -o pipefail @@ -66,9 +70,9 @@ if [ -n "${NODEJS_VER}" ]; then rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md} echo "$node_install_path" echo "${NODEJS_UNTAR}" - sudo rsync -av "${NODEJS_UNTAR}/" "$node_install_path/" + $sudo_cmd rsync -av "${NODEJS_UNTAR}/" "$node_install_path/" echo "Done copying" - sudo chown -R $(whoami) "$node_install_path/lib/node_modules/" - sudo chown $(whoami) ""$node_install_path"/bin/" + $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/" + $sudo_cmd chown $(whoami) ""$node_install_path"/bin/" fi \ No newline at end of file