diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-09-03 14:26:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-09-03 14:26:40 +0200 |
commit | 1a8cc5a63d495da8d9fbddec28aded237942e5ef (patch) | |
tree | 79a1e53aa2453c0ac7d0ecb047d5dc8537dd7383 | |
parent | 4ba36c72e474cecf94672926dc17d61f0ee275fd (diff) |
Only use default sudo for default installation directory in build.sh
-rwxr-xr-x | build.sh | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -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 |