tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] pkg_rolling-replace: use POSIX getopts(1) instead of getopt(1)



pkg_rolling-replace is missing a dependency on misc/getopt. Thoughts
on porting it to POSIX getopts(1) instead?
---
 pkgtools/pkg_rolling-replace/Makefile         |  2 +-
 .../files/pkg_rolling-replace.sh              | 38 ++++++++-----------
 2 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/pkgtools/pkg_rolling-replace/Makefile b/pkgtools/pkg_rolling-replace/Makefile
index 4d72ec44b23..ea5cb4bd580 100644
--- a/pkgtools/pkg_rolling-replace/Makefile
+++ b/pkgtools/pkg_rolling-replace/Makefile
@@ -1,6 +1,6 @@
 # $NetBSD: Makefile,v 1.49 2021/04/22 08:54:18 pho Exp $
 
-PKGNAME=	pkg_rolling-replace-0.24.12
+PKGNAME=	pkg_rolling-replace-0.24.13
 CATEGORIES=	pkgtools
 
 MAINTAINER=	gdt%NetBSD.org@localhost
diff --git a/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
index c1bbb6b32b2..1bd5aaec933 100755
--- a/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
+++ b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
@@ -345,29 +345,23 @@ EXCLUDE=
 MAKE_VAR="IN_PKG_ROLLING_REPLACE=1"
 MAKE_VAR_SEP=" "
 
-args=$(getopt BFhknursvD:x:X:L: $*)
-if [ $? -ne 0 ]; then
-    opt_h=1
-fi
-set -- $args
-while [ $# -gt 0 ]; do
-    case "$1" in
-        -B) opt_B=-B ;;
-        -F) opt_F=1 ;;
-        -h) opt_h=1 ;;
-        -k) opt_k=1 ;;
-        -n) opt_n=1 ;;
-        -r) opt_r=1 ;;
-        -s) opt_s=1 ;;
-        -u) opt_u=1 ;;
-        -v) opt_v=1 ;;
-	-D) MAKE_VAR="${MAKE_VAR}${MAKE_VAR_SEP}$2"; MAKE_VAR_SEP=" "; shift ;;
-        -x) EXCLUDE="$EXCLUDE $(echo $2 | sed 's/,/ /g')" ; shift ;;
-        -X) REALLYEXCLUDE="$REALLYEXCLUDE $(echo $2 | sed 's/,/ /g')" ; shift ;;
-        -L) LOGPATH="$2"; shift ;;
-        --) shift; break ;;
+while getopts BFhknursvD:x:X:L: opt; do
+    case "$opt" in
+        B) opt_B=-B ;;
+        F) opt_F=1 ;;
+        h) opt_h=1 ;;
+        k) opt_k=1 ;;
+        n) opt_n=1 ;;
+        r) opt_r=1 ;;
+        s) opt_s=1 ;;
+        u) opt_u=1 ;;
+        v) opt_v=1 ;;
+        D) MAKE_VAR="${MAKE_VAR}${MAKE_VAR_SEP}$OPTARG"; MAKE_VAR_SEP=" " ;;
+        x) EXCLUDE="$EXCLUDE $(echo $OPTARG | sed 's/,/ /g')" ;;
+        X) REALLYEXCLUDE="$REALLYEXCLUDE $(echo $OPTARG | sed 's/,/ /g')" ;;
+        L) LOGPATH="$OPTARG" ;;
+        ?) opt_h=1 ;;
     esac
-    shift
 done
 
 if [ -n "$opt_h" ]; then
-- 
2.31.1



Home | Main Index | Thread Index | Old Index