summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximilian attems <maks@debian.org>2005-10-21 18:50:53 +0200
committermaximilian attems <maks@debian.org>2005-10-21 18:50:53 +0200
commit46727679e6e5bfdb67268511dc7a91a7a828abd7 (patch)
tree468f5d9005b31c5e0ff6ee37daf7827eb52e7540
parentbee1355e2c21a86751648b6f0df8a6e4e4e5a45d (diff)
downloadinitramfs-tools-46727679e6e5bfdb67268511dc7a91a7a828abd7.tar.gz
initramfs-tools-46727679e6e5bfdb67268511dc7a91a7a828abd7.zip
jonas: use gnu getopt instead of getopts
-rw-r--r--debian/changelog5
-rwxr-xr-xmkinitramfs40
2 files changed, 34 insertions, 11 deletions
diff --git a/debian/changelog b/debian/changelog
index 00643e0..4b75eec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,7 +41,10 @@ initramfs-tools (0.31) UNRELEASED; urgency=low
* Make us a bit more silent/tidy by default, unless "quiet" isn't on
the kernel's command line (then we're just as verbose as ever)
- -- maximilian attems <maks@sternwelten.at> Sun, 16 Oct 2005 19:22:55 +0200
+ [ Jonas Smedegaard ]
+ * Use GNU getopt (instead of bash builtin getopts) for improved handling.
+
+ -- Jonas Smedegaard <dr@jones.dk> Tue, 18 Oct 2005 04:03:48 +0200
initramfs-tools (0.31) unstable; urgency=low
diff --git a/mkinitramfs b/mkinitramfs
index e870489..bcf640b 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -10,27 +10,47 @@ errors_to="2>/dev/null"
# BUSYBOXDIR="/usr/lib/initramfs-tools/bin/"
BUSYBOXDIR="/bin"
-while getopts "d:ko:r:" flag; do
- case $flag in
- d)
- CONFDIR="${OPTAGS}"
+OPTIONS=`getopt -o d:ko:r: -n "$0" -- "$@"`
+
+# Check for non-GNU getopt
+if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+
+eval set -- "$OPTIONS"
+
+while true; do
+ case "$1" in
+ -d)
+ CONFDIR="$2"
+ shift 2
if [ ! d "${CONFDIR}" ]; then
echo "${0}: ${CONFDIR}: Not a directory" >&2
exit 1
fi
;;
- o)
- touch ${OPTARG}
- outfile="$(readlink -f ${OPTARG})"
+ -o)
+ touch $2
+ shift $2
+ outfile="$(readlink -f $2)"
;;
- k)
+ -k)
keep="y"
+ shift
+ ;;
+ -r)
+ # ignore (FIXME: manpage says differently?!?)
+ shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Internal error!" >&2
+ exit 1
;;
esac
done
-shift $((${OPTIND} - 1))
-
# For dependency ordered mkinitramfs hook scripts.
. /usr/share/initramfs-tools/scripts/functions
. /usr/share/initramfs-tools/hook-functions