tech-pkg archive

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

audit-packages.sh vs getopt



Hi:
No getopt on QNX :( Here's a page from build.sh
-seanb
Index: audit-packages.sh.in
===================================================================
--- audit-packages.sh.in 
(.../vendor/HEAD/pkgsrc/pkgtools/pkg_install/files/admin/audit-packages.sh.in) 
(revision 136)
+++ audit-packages.sh.in 
(.../HEAD_640/pkgsrc/pkgtools/pkg_install/files/admin/audit-packages.sh.in) 
(revision 136)
@@ -24,26 +24,48 @@
 do_limit_type=
 do_print_var=
 
-args=`getopt F:K:Q:Vc:deg:h:n:p:qst:v $*`
-if [ $? -ne 0 ]; then
- usage 1 2
+opts='F:K:Q:Vc:deg:h:n:p:qst:v'
+
+
+if type getopts >/dev/null 2>&1; then
+ # Use POSIX getopts.
+ #
+ getoptcmd='getopts ${opts} opt && opt=-${opt}'
+ optargcmd=':'
+ optremcmd='shift $((${OPTIND} -1))'
+else
+ type getopt >/dev/null 2>&1 ||
+ echo "/bin/sh shell is too old; try ksh or bash" && exit 1
+
+ # Use old-style getopt(1) (doesn't handle whitespace in args).
+ #
+ args="$(getopt ${opts} $*)"
+ if [ $? -ne 0 ]; then
+ usage 1 2
+ fi
+ set -- ${args}
+
+ getoptcmd='[ $# -gt 0 ] && opt="1ドル" && shift'
+ optargcmd='OPTARG="1ドル"; shift'
+ optremcmd=':'
 fi
 
-set -- $args
 
-while [ $# -gt 0 ]; do
- case "1ドル" in
+
+
+while eval ${getoptcmd}; do
+ case ${opt} in
 -F)
- do_check_file=2ドル
- shift
+ eval ${optargcmd}
+ do_check_file=${OPTARG}
 ;;
 -K)
- do_pkgdb="1ドル 2ドル"
- shift
+ eval ${optargcmd}
+ do_pkgdb="${opt} ${OPTARG}"
 ;;
 -Q)
- do_print_var="2ドル"
- shift
+ eval ${optargcmd}
+ do_print_var="${OPTARG}"
 ;;
 -V)
 exec ${pkg_admin} -V
@@ -65,16 +87,16 @@
 exit 1
 ;;
 -h)
- do_check_vul_file=2ドル
- shift
+ eval ${optargcmd}
+ do_check_vul_file="${OPTARG}"
 ;;
 -n)
- do_check_pattern=2ドル
- shift
+ eval ${optargcmd}
+ do_check_pattern="${OPTARG}"
 ;;
 -p)
- do_check_installed=2ドル
- shift
+ eval ${optargcmd}
+ do_check_installed="${OPTARG}"
 ;;
 -q)
 do_quiet=-q
@@ -83,14 +105,13 @@
 do_sign=-s
 ;;
 -t)
- do_limit_type="-t 2ドル"
- shift
+ eval ${optargcmd}
+ do_limit_type="${opt} ${OPTARG}"
 ;;
 -v)
 do_verbose="$do_verbose -v"
 ;;
 esac
- shift
 done
 
 if [ -n "${do_fetch}" ]; then


Home | Main Index | Thread Index | Old Index

AltStyle によって変換されたページ (->オリジナル) /