From 061773dd9f87627da9099d622bb0ab7d69f9e88c Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 24 Jan 2019 16:01:04 +0100 Subject: [PATCH] add die function for pacstrap-docker --- pacstrap-docker | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pacstrap-docker b/pacstrap-docker index 9c6eb46..918b451 100755 --- a/pacstrap-docker +++ b/pacstrap-docker @@ -1,11 +1,15 @@ #!/bin/bash +out() { printf "$1 $2\n" "${@:3}"; } +error() { out "==> ERROR:" "$@"; } >&2 +die() { error "$@"; exit 1; } + (( $# )) || die "No root directory specified" newroot=$1; shift pacman_args=("${@:-base}") if [[ $EUID -ne 0 ]]; then - die "This script must be run as root" + die "This script must be run as root" fi umask @@ -19,5 +23,5 @@ mkdir -m 0555 -p "$newroot"/{sys,proc} echo 'Installing packages to %s' "$newroot" if ! pacman -r "$newroot" -Sy --noconfirm "${pacman_args[@]}"; then - die 'Failed to install packages to new root' + die 'Failed to install packages to new root' fi