diff options
author | paltherr <paltherr@epfl.ch> | 2003-10-23 06:56:52 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-10-23 06:56:52 +0000 |
commit | fa860129191cbb88541d069ba014d2c5237e1d54 (patch) | |
tree | fedba27ef1310462535be8d197e69a6bd8348848 /support | |
parent | 1e58e5873daf41c29b342426de3fc221a8d1d0d9 (diff) | |
download | scala-fa860129191cbb88541d069ba014d2c5237e1d54.tar.gz scala-fa860129191cbb88541d069ba014d2c5237e1d54.tar.bz2 scala-fa860129191cbb88541d069ba014d2c5237e1d54.zip |
- Improved stdlib.sh
- Adapted install.sh & mirror.sh
Diffstat (limited to 'support')
-rw-r--r-- | support/scripts/install.sh | 13 | ||||
-rw-r--r-- | support/scripts/mirror.sh | 7 | ||||
-rw-r--r-- | support/scripts/stdlib.sh | 37 |
3 files changed, 33 insertions, 24 deletions
diff --git a/support/scripts/install.sh b/support/scripts/install.sh index 5af2ed2a97..352b47f75a 100644 --- a/support/scripts/install.sh +++ b/support/scripts/install.sh @@ -86,6 +86,7 @@ function install-files() { } function install() { + local program="$FUNCNAME"; local version='$Revision$'; local directory="false"; local leading="false"; @@ -95,14 +96,14 @@ function install() { local preserve="false"; local -a files; - args-loop "$FUNCNAME" "$@"; + args-loop "$@"; local count="${#files[@]}"; if [ $count -lt 1 ]; then if [ "$directory" == "true" ]; then - abort "$FUNCNAME: missing target directory"; + abort "missing target directory"; else - abort "$FUNCNAME: missing source file"; + abort "missing source file"; fi; fi; @@ -110,7 +111,7 @@ function install() { install-dirs "${files[@]}"; else if [ $count -lt 2 ]; then - abort "$FUNCNAME: missing destination"; + abort "missing destination"; fi; local last="${files[$(($count-1))]}"; @@ -120,8 +121,8 @@ function install() { elif [ $count -eq 2 ]; then install-file "${files[@]}"; else - local text1="$FUNCNAME: installing multiple files, but last"; - local text2="argument, \`$last' is not a directory"; + local text1="installing multiple files, but last"; + local text2="argument, '$last' is not a directory"; abort "$text1 $text2"; fi; fi; diff --git a/support/scripts/mirror.sh b/support/scripts/mirror.sh index 4b6a0df60b..64848ed538 100644 --- a/support/scripts/mirror.sh +++ b/support/scripts/mirror.sh @@ -39,6 +39,7 @@ function mirror-files() { } function mirror() { + local program="$FUNCNAME"; local version='$Revision$'; local prefix="."; local owner=""; @@ -47,15 +48,15 @@ function mirror() { local preserve="false"; local -a files; - args-loop "$FUNCNAME" "$@"; + args-loop "$@"; if [ ! -d "$prefix" ]; then - abort "$FUNCNAME: could not find directory \`$prefix'"; + abort "could not find directory '$prefix'"; fi; local count="${#files[@]}"; if [ $count -lt 1 ]; then - abort "$FUNCNAME: missing target directory"; + abort "missing target directory"; fi; local -a instargs; diff --git a/support/scripts/stdlib.sh b/support/scripts/stdlib.sh index 2a472f104a..fe78a56eef 100644 --- a/support/scripts/stdlib.sh +++ b/support/scripts/stdlib.sh @@ -11,39 +11,46 @@ function print() { } function abort() { - print "$@" 1>&2; + print "${program:-error}: ""$@" 1>&2; exit 1; } -function run() { - [ "$verbose" = "true" ] && echo "$@"; +function run_() { "$@" || exit $?; } -############################################################################## +function run() { + [ "$verbose" = "true" ] && echo "$@"; + run_ "$@"; +} -# usage: args-abort <error> -# abort argument processing with message <error> -function args-abort() { - local error="$1"; - shift 1; - abort "$args_script: $error" "$@"; +function runO() { + local stdout="$1"; shift 1; + [ "$verbose" = "true" ] && echo "$@" "1>" "$stdout"; + run_ "$@" 1> "$stdout"; } +############################################################################## + # usage: args-loop <script> "$@" # process all arguments function args-loop() { - local args_script="$1"; shift 1; while [ $# -gt 0 ]; do - $args_script-args "$@"; + $program-args "$@"; shift $?; done; } # usage: args-option-unknown "$@" -# <option> ... => abort "unknown <option>"; +# <option> ... => abort "unknown option <option>"; function args-option-unknown() { - args-abort "unknown option $1"; + abort "unknown option $1"; +} + +# usage: args-unknown "$@" +# <argument> ... => abort "don't know what to do with argument <argument>"; +function args-unknown() { + abort "don't know what to do with argument '$1'"; } # usage: args-append-array <array> "$@" @@ -59,7 +66,7 @@ function args-append-array() { function args-option-value() { local value="$1"; shift 1; if [ $# -lt 2 ]; then - args-abort "missing argument for option $1"; + abort "missing argument for option $1"; fi; eval "$value=\"\$2\""; return 2; |