live-build/functions/arguments.sh

102 lines
1.5 KiB
Bash
Raw Normal View History

2007-09-23 08:04:48 +00:00
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2016-2020 The Debian Live team
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program 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.
2007-09-23 08:04:48 +00:00
Arguments ()
{
local ARGUMENTS
local ERR=0
ARGUMENTS="$(getopt --longoptions breakpoints,color,no-color,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options c:huv --shell sh -- "${@}")" || ERR=$?
2007-09-23 08:04:48 +00:00
if [ $ERR -eq 1 ]; then
Echo_error "invalid arguments"
exit 1
elif [ $ERR -ne 0 ]; then
Echo_error "getop failure"
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)
_BREAKPOINTS="true"
2007-09-23 08:05:17 +00:00
shift
2007-09-23 08:04:49 +00:00
;;
--color)
_COLOR="true"
_COLOR_OUT="true"
_COLOR_ERR="true"
shift
;;
--no-color)
_COLOR="false"
_COLOR_OUT="false"
_COLOR_ERR="false"
shift
;;
-c|--conffile)
_CONFFILE="${2}"
2007-09-23 08:05:17 +00:00
shift 2
2007-09-23 08:04:48 +00:00
;;
--debug)
_DEBUG="true"
2007-09-23 08:05:17 +00:00
shift
2007-09-23 08:04:48 +00:00
;;
--force)
_FORCE="true"
2007-09-23 08:05:17 +00:00
shift
2007-09-23 08:04:48 +00:00
;;
-h|--help)
Man
2007-09-23 08:05:17 +00:00
shift
2007-09-23 08:04:51 +00:00
;;
2007-09-23 08:04:48 +00:00
--quiet)
_QUIET="true"
2007-09-23 08:05:17 +00:00
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)
_VERBOSE="true"
2007-09-23 08:05:17 +00:00
shift
2007-09-23 08:04:48 +00:00
;;
-v|--version)
2012-07-18 19:38:58 +00:00
echo "${VERSION}"
exit 0
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
}