live-build/functions/arguments.sh

82 lines
1.2 KiB
Bash
Raw Normal View History

2007-09-23 08:04:48 +00:00
#!/bin/sh
# arguments.sh - handle common arguments
2008-03-06 14:43:00 -01:00
# Copyright (C) 2006-2008 Daniel Baumann <daniel@debian.org>
2007-09-23 08:04:48 +00:00
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.
Arguments ()
{
ARGUMENTS="$(getopt --longoptions breakpoints,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options c:huv --shell sh -- "${@}")"
2007-09-23 08:04:48 +00:00
if [ "${?}" != "0" ]
then
2007-09-23 08:04:49 +00:00
Echo_error "terminating" >&2
2007-09-23 08:04:48 +00:00
exit 1
fi
eval set -- "${ARGUMENTS}"
while true
do
case "${1}" in
2007-09-23 08:04:49 +00:00
--breakpoints)
2007-09-23 08:05:17 +00:00
LH_BREAKPOINTS="enabled"
shift
2007-09-23 08:04:49 +00:00
;;
-c|--conffile)
2007-09-23 08:05:17 +00:00
LH_CONFFILE="${2}"
shift 2
2007-09-23 08:04:48 +00:00
;;
--debug)
2007-09-23 08:05:17 +00:00
LH_DEBUG="enabled"
shift
2007-09-23 08:04:48 +00:00
;;
--force)
_FORCE="enabled"
2007-09-23 08:05:17 +00:00
shift
2007-09-23 08:04:48 +00:00
;;
-h|--help)
2007-09-23 08:05:17 +00:00
Help
shift
2007-09-23 08:04:51 +00:00
;;
2007-09-23 08:04:48 +00:00
--quiet)
2007-09-23 08:05:17 +00:00
LH_QUIET="enabled"
shift
2007-09-23 08:04:48 +00:00
;;
-u|--usage)
2007-09-23 08:05:17 +00:00
Usage
shift
2007-09-23 08:04:48 +00:00
;;
--verbose)
2007-09-23 08:05:17 +00:00
LH_VERBOSE="enabled"
shift
2007-09-23 08:04:48 +00:00
;;
-v|--version)
2007-09-23 08:05:17 +00:00
Version
shift
2007-09-23 08:04:48 +00:00
;;
--)
2007-09-23 08:05:17 +00:00
shift
break
2007-09-23 08:04:48 +00:00
;;
*)
Echo_error "internal error %s" "${0}"
2007-09-23 08:04:48 +00:00
exit 1
;;
esac
done
}