From 1a8cc5a63d495da8d9fbddec28aded237942e5ef Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 3 Sep 2016 14:26:40 +0200 Subject: Only use default sudo for default installation directory in build.sh --- build.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 7b267c9..080f9cd 100755 --- a/build.sh +++ b/build.sh @@ -38,8 +38,9 @@ run () owd="$(pwd)" cxx= -idir="/usr/local" -sudo="sudo" +idir= +sudo= +sudo_set= while test $# -ne 0; do case $1 in @@ -47,11 +48,11 @@ while test $# -ne 0; do diag diag "$usage" diag - diag "By default the script will install into /usr/local using sudo. To" - diag "instruct the script not to use a sudo program, pass empty value to" - diag "the --sudo option, for example:" + diag "By default the script will install into /usr/local using sudo (1)." + diag "To use sudo for a custom installation directory you need to specify" + diag "the sudo program explicitly, for example:" diag - diag "$0 --install-dir /tmp/build2 --sudo '' g++" + diag "$0 --install-dir /opt/build2 --sudo sudo g++" diag diag "See the INSTALL file for details." diag @@ -75,6 +76,7 @@ while test $# -ne 0; do exit 1 fi sudo="$1" + sudo_set="y" shift ;; *) @@ -90,6 +92,17 @@ if test -z "$cxx"; then exit 1 fi +# Only use default sudo for the default installation directory and only if +# it wasn't specified by the user. +# +if test -z "$idir"; then + idir="/usr/local" + + if test -z "$sudo_set"; then + sudo="sudo" + fi +fi + if test -f build/config.build; then diag "current directory already configured, start with clean source" exit 1 -- cgit v1.1