Commit 11bdaa74 by Natanael Copa Committed by Stéphane Graber

lxc-destroy: use posix shell instead of bash

- avoid use getopt --longoptions Signed-off-by: 's avatarNatanael Copa <ncopa@alpinelinux.org> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 2a9a0a08
#!/bin/bash #!/bin/sh
# #
# lxc: linux Container library # lxc: linux Container library
...@@ -39,38 +39,47 @@ help() { ...@@ -39,38 +39,47 @@ help() {
echo " -f stop the container if it is running (rather than abort)" >&2 echo " -f stop the container if it is running (rather than abort)" >&2
} }
shortoptions='hn:f' usage_err() {
longoptions='help,name:' [ -n "$1" ] && echo "$1" >&2
lxc_path=@LXCPATH@
force=0
getopt=$(getopt -o $shortoptions --longoptions $longoptions -- "$@")
if [ $? != 0 ]; then
usage usage
exit 1; exit 1
fi }
eval set -- "$getopt" optarg_check() {
if [ -z "$2" ]; then
usage_err "option '$1' requires an argument"
fi
}
while true; do lxc_path=@LXCPATH@
case "$1" in force=0
while [ $# -gt 0 ]; do
opt="$1"
shift
case "$opt" in
-h|--help) -h|--help)
help help
exit 1 exit 1
;; ;;
-n|--name) -n|--name)
shift optarg_check "$opt" "$1"
lxc_name=$1 lxc_name=$1
shift shift
;; ;;
-f) -f)
force=1 force=1
shift
;; ;;
--) --)
shift
break break
;; ;;
-?)
usage_err "unknown option '$opt'"
;;
-*)
# split opts -abc into -a -b -c
set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
;;
*) *)
usage usage
exit 1 exit 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment