From 380b86394e0cb71ef4e6297ad72092ebdd9bd80a Mon Sep 17 00:00:00 2001 From: ranke Date: Mon, 14 Dec 2015 06:58:11 +0000 Subject: Report usage on invalid options, don't use getopts in backport_others git-svn-id: svn+ssh://stiller/home/schatz/reps/r-backports@113 f247ebf9-aa24-0410-a698-f940e971ad2b --- backport | 1 + backport_others | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/backport b/backport index 2eb6b05..4761ee2 100755 --- a/backport +++ b/backport @@ -44,6 +44,7 @@ while test -n "${1}"; do ;; -*) echo "Error: Unknown option: $1" >&2 + usage exit 1 ;; *) # No more options diff --git a/backport_others b/backport_others index 5e5ab1c..6e92116 100644 --- a/backport_others +++ b/backport_others @@ -12,26 +12,34 @@ echo "Options:" echo " -s Skip apt-get update/upgrade and pbuilder update" } +# Loop over options skip=false -while getopts ":s" flag; do - case $flag in - s) +while test -n "${1}"; do + case "$1" in + -s | --skip) skip=true + shift ;; - \?) - echo "Invalid option: -$OPTARG" >&2 + -*) + echo "Error: Unknown option: $1" >&2 + usage + exit 1 + ;; + *) # No more options + break ;; esac - shift $((OPTIND-1)) done -# Check for number of arguments +# Positional arguments if [ $# -lt 1 ]; then usage; exit 1; fi DIST=$1 # Update pbuilder chroot -if [ "$skip" = true ] +if [ "$skip" = false ] then + sudo apt-get update + sudo apt-get upgrade sudo -E pbuilder update fi @@ -43,7 +51,8 @@ export DIST # built first, then nlme and rmatrix, then the rest # Packages to backport to squeeze/wheezy/jessie (without rpy2): -for i in lattice nlme rmatrix mgcv boot cluster codetools foreign kernsmooth r-cran-class r-cran-coda r-cran-spatial r-cran-nnet r-cran-mass rodbc rpart survival r-cran-littler rpy rkward r-cran-rjags; do +for i in lattice nlme r-cran-coda littler; do +#for i in lattice nlme rmatrix mgcv boot cluster codetools foreign kernsmooth r-cran-class r-cran-coda r-cran-spatial r-cran-nnet r-cran-mass rodbc rpart survival r-cran-littler rpy rkward r-cran-rjags; do ./backport -s $i $DIST -- cgit v1.2.1