summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/librechroot16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index c8b83f8..378222b 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -296,7 +296,8 @@ main() {
declare -i retconf=0
load_conf chroot.conf CHROOTDIR CHROOT || retconf=$?
- local mode=enter
+ local mode=enter opt
+ declare -Ai used_opts
while getopts 'n:l:NC:M:A:w:r:' opt; do
case $opt in
n) CHROOT=$OPTARG;;
@@ -320,7 +321,20 @@ main() {
r) sysd_nspawn_flags+=("--bind-ro=$OPTARG");;
*) usage >&2; return $EXIT_INVALIDARGUMENT;;
esac
+ used_opts[$opt]+=1
done
+ for opt in n l C M A; do
+ if (( ${used_opts[$opt]:-0} > 1 )); then
+ error "Option -%s may only be given once"
+ usage >&2
+ return $EXIT_INVALIDARGUMENT
+ fi
+ done
+ if (( ${used_opts[A]:-0} && ( ${used_opts[C]:-0} || ${used_opts[M]:-0} ) )); then
+ error "Option -A may not be used together with -C or -M"
+ usage >&2
+ return $EXIT_INVALIDARGUMENT
+ fi
shift $((OPTIND - 1))
if [[ $# -lt 1 ]]; then
error "Must specify a command"