diff options
author | Erich Eckner <git@eckner.net> | 2020-07-01 08:53:30 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-07-01 08:53:30 +0200 |
commit | f007efbcd2982705c0f929b89caa940af3992797 (patch) | |
tree | 7947295aa1ebc52a0604ddda06ad26d7781df6f8 | |
parent | 97611fa6c92880a7ae75755db6ab9f74e9f9bc79 (diff) | |
download | archlinuxewe.git.save-f007efbcd2982705c0f929b89caa940af3992797.tar.xz |
bumpPkgrel: make immune against permutation of arguments
-rwxr-xr-x | bumpPkgrel | 51 |
1 files changed, 37 insertions, 14 deletions
@@ -1,30 +1,53 @@ #!/bin/bash -if [ $# -eq 0 ]; then +usage() { >&2 echo 'usage: bumpPkgrel [-n] [-p /tmp/provided] $pkg1 $pkg2 $pkg3 ...' >&2 echo ' -n: do not commit' >&2 echo ' -p: use this temporary file' exit 1 -fi +} -if [ "x$1" = 'x-n' ]; then - commit=false - commit_flag='-n' - shift -else - commit=true - commit_flag='' -fi +eval set -- "$( + getopt -o np: \ + -n "$(basename "$0")" \ + -- "$@" \ + || echo "usage" +)" -if [ "x$1" = 'x-p' ]; then - shift - provided="$1" +commit=true +commit_flag='' +provided='' + +while true; do + case "$1" in + '-n') + commit=false + commit_flag='-n' + ;; + '-p') + shift + provided="$1" + ;; + '--') + shift + break + ;; + *) + >&2 printf 'FEHLER: Verstehe Option "%s" doch nicht! Ich beende.\n' "$1" + exit 1 + esac shift -else +done + +if [ -z "${provided}" ]; then provided=$("${0%/*}/liste-verfuegbare-Versionen") trap 'rm -f "${provided}"' EXIT fi +if [ $# -eq 0 ]; then + usage +fi + pin_dependency() { sed ' s/^\(\S\+\)>\?=\(\S\+\)$/\1 \2/ |