syntax check before parsing config files
[grml-debootstrap.git] / grml-debootstrap
index 97409bc..5173dc1 100755 (executable)
@@ -346,6 +346,7 @@ stage() {
 
 # source main configuration file {{{
 if [ -r /etc/debootstrap/config ] ; then
+  bash -n /etc/debootstrap/config
   # shellcheck disable=SC1091
   . /etc/debootstrap/config
 fi
@@ -354,11 +355,10 @@ fi
 # cmdline handling {{{
 CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,defaultinterfaces,interactive,nodebootstrap,nointerfaces,nokernel,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,post-scripts:,pre-scripts:,debconf:,vm,vmfile,vmsize:,vmefi,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,efi:,arch:,insecure,verbose,help,version,force,debug,contrib,non-free,remove-configs,sshcopyid,sshcopyauth
 
-_opt_temp=$(getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \
-  $CMDLINE_OPTS -- "$@")
-
-if [ $? != 0 ]; then
-  eerror "Try 'grml-debootstrap --help' for more information."; eend 1; exit 1
+if ! _opt_temp=$(getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \
+  $CMDLINE_OPTS -- "$@"); then
+  eerror "Try 'grml-debootstrap --help' for more information."
+  bailout 1
 fi
 eval set -- "$_opt_temp"
 
@@ -658,6 +658,7 @@ fi
 # source specified configuration file {{{
 if [ -n "$CONFIGFILE" ] ; then
   einfo "Reading specified config file $CONFIGFILE."
+  bash -n "$CONFIGFILE"
   # shellcheck disable=SC1091 source=config
   if ! . "$CONFIGFILE" ; then
     eerror "Error reading config file $CONFIGFILE" ; bailout 1
@@ -1051,8 +1052,7 @@ elif [ -n "$INTERACTIVE" ] ; then
 Is this ok for you? Notice: selecting 'No' will exit ${PN}."
 
    dialog --title "$PN" --no-collapse \
-          --yesno "$INFOTEXT" 0 0
-   [ $? -eq 0 ] || bailout 0
+          --yesno "$INFOTEXT" 0 0 || bailout 0
 
 else # if not running automatic installation display configuration and prompt for execution:
    einfo "$PN [${VERSION}] - Please recheck configuration before execution:"