From b9cf989234d37a0885ee6228bcb6fa8f20f72b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Apestegu=C3=ADa?= Date: Tue, 17 Oct 2023 15:37:04 +0200 Subject: [PATCH] bsdinstall: Fail nicely in jail target If the directory is empty we fail with a message regarding mkdir in which the empty directory can't be seen because it is not quoted. Show a nice message so the user knows what is going on. Reviewed by: bapt@ Differential Revision: https://reviews.freebsd.org/D42252 --- usr.sbin/bsdinstall/scripts/jail | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/jail b/usr.sbin/bsdinstall/scripts/jail index feb9d8b1c09..de6dee04b89 100755 --- a/usr.sbin/bsdinstall/scripts/jail +++ b/usr.sbin/bsdinstall/scripts/jail @@ -36,7 +36,6 @@ BSDCFG_SHARE="/usr/share/bsdconfig" : ${BSDDIALOG_OK=0} f_dprintf "Began Installation at %s" "$( date )" -export BSDINSTALL_CHROOT=$1 error() { local msg @@ -54,6 +53,11 @@ error() { fi } +if [ -z "$1" ]; then + error "Directory can not be empty\n\nUsage:\nbsdinstall jail directory" +fi +export BSDINSTALL_CHROOT=$1 + rm -rf $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC mkdir -p $1 || error "mkdir failed for $1"