From 0cdd803ba09d130eb7a4a57c80aa5053b70b48e1 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Fri, 21 Sep 2018 18:57:34 +0200 Subject: [PATCH] store valid modes in an array --- mmdebstrap | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index faa6112..d6803fc 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -988,10 +988,9 @@ sub main() { if ($options->{mode} eq 'sudo') { $options->{mode} = 'root'; } - if ($options->{mode} ne 'auto' and $options->{mode} ne 'root' - and $options->{mode} ne 'fakechroot' - and $options->{mode} ne 'proot' and $options->{mode} ne 'unshare') { - die "invalid mode. Choose from auto, root, fakechroot, proot, unshare"; + my @valid_modes = ('auto', 'root', 'unshare', 'fakechroot', 'proot'); + if (!grep { $_ eq $options->{mode} } @valid_modes) { + die "invalid mode. Choose from " . (join ', ', @valid_modes); } if ($options->{variant} eq 'essential' and defined $options->{include}) {