From ff1b729f956889973994dcc24eb208c7e99a014f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 3 Jul 2011 12:35:31 -0400 Subject: unify error messaging, both in grammar and output This also removes a superfluous check on MODULEDIR, which is already covered by get_kernver. Signed-off-by: Dave Reisner --- functions | 8 ++++---- mkinitcpio | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/functions b/functions index ffb00ec..ac0617c 100644 --- a/functions +++ b/functions @@ -162,7 +162,7 @@ add_module() { done < <(modinfo -b "$BASEDIR" -k "$KERNELVERSION" -0 "$module" 2>/dev/null) if [[ -z $path ]]; then - error "module '$module' not found" + error "module not found: \`%s'" "$module" return 1 fi @@ -229,11 +229,11 @@ add_file() { src=$BASEDIR$1 - [[ -f "$src" ]] || { error "$src: No such file"; return 1; } + [[ -f "$src" ]] || { error "file not found: \`%s'" "$src"; return 1; } mode=$(stat -c %a "$src") if [[ -z "$mode" ]]; then - error "failed to stat file: \`$src'" + error "failed to stat file: \`%s'." "$src" return 1 fi @@ -251,7 +251,7 @@ add_binary() { binary=$BASEDIR$1 - [[ -f "$binary" ]] || { error "$binary not found"; return 1; } + [[ -f "$binary" ]] || { error "file not found: \`%s'" "$binary"; return 1; } dest=${2:-$binary} mode=$(stat -c %a "$binary") diff --git a/mkinitcpio b/mkinitcpio index 434172e..0b2a573 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -163,7 +163,7 @@ readonly NC BOLD BLUE GREEN RED YELLOW if [[ $BASEDIR ]]; then # resolve the path. it might be a relative path and/or contain symlinks if ! pushd "$BASEDIR" &>/dev/null; then - die "base directory '$BASEDIR' does not exist or is not a directory" + die "base directory does not exist or is not a directory: \`%s'" "$BASEDIR" fi BASEDIR=$(pwd -P) BASEDIR=${BASEDIR%/} @@ -172,13 +172,14 @@ fi if [[ $optkver ]]; then if ! KERNELVERSION=$(get_kernver "$optkver"); then - die "'$optkver' is an invalid kernel specifier" + [[ ${optkver:0:1} == / ]] && optkver=$BASEDIR$optkver + die "invalid kernel specifier: \`%s'" "$optkver" fi fi if [[ $TMPDIR ]]; then if [[ ! -d $TMPDIR ]]; then - error "'$TMPDIR' does not exist or is not a directory" + error "Temporary directory does not exist or is not a directory: \`%s'" "$TMPDIR" unset TMPDIR cleanup 1 fi @@ -207,7 +208,7 @@ if [[ $PRESET ]]; then if [[ ${!preset_kver:-$ALL_kver} ]]; then preset_cmd+=(-k "${!preset_kver:-$ALL_kver}") else - warning "No kernel version specified. Skipping image '%s'" "$p" + warning "No kernel version specified. Skipping image \`%s'" "$p" continue fi @@ -215,7 +216,7 @@ if [[ $PRESET ]]; then if [[ ${!preset_config:-$ALL_config} ]]; then preset_cmd+=(-c "$BASEDIR${!preset_config:-$ALL_config}") else - warning "No configuration file specified. Skipping image '%s'" "$p" + warning "No configuration file specified. Skipping image \`%s'" "$p" continue fi @@ -223,7 +224,7 @@ if [[ $PRESET ]]; then if [[ ${!preset_image} ]]; then preset_cmd+=(-g "$BASEDIR${!preset_image}") else - warning "No image file specified. Skipping image '%s'" "$p" + warning "No image file specified. Skipping image \`%s'" "$p" continue fi @@ -237,19 +238,19 @@ if [[ $PRESET ]]; then done cleanup 0 else - die "Preset $PRESET does not exist. Exiting." + die "Preset not found: \`%s'" "$PRESET" fi fi if [[ $GENIMG ]]; then IMGPATH=$(readlink -f "$GENIMG") if [[ -z $IMGPATH || ! -w ${IMGPATH%/*} ]]; then - die "error: unable to write to path: '$GENIMG'" + die "error: unable to write to path: \`%s'" "$GENIMG" fi fi if [[ ! -f "$CONFIG" ]]; then - die "config file '$CONFIG' cannot be found, aborting..." + die "Config file does not exist: \`%s'" " $CONFIG" fi . "$CONFIG" -- cgit v1.2.3-24-g4f1b