Skip to content

Commit

Permalink
standardize error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
zpiatt committed Dec 22, 2022
1 parent 3c23071 commit dad3b85
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gen
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ which_ed() {

create_one() {
if [[ -e "$filename" ]]; then
printf "%s already exists.\n" "$filename"; exit 1
printf "gen: file '%s' already exists.\n" "$filename"; exit 1
else
if ! touch "$filename" 2> /dev/null; then
printf "gen: cannot generate '%s': Permission denied\n" "$filename"; exit 1
Expand All @@ -158,7 +158,7 @@ create_multi() {
new="${filename}${i}"
fi
if [[ -e "$new" ]]; then
printf "%s already exists.\n" "$new"; exit 1
printf "gen: file '%s' already exists.\n" "$new"; exit 1
else
if ! touch "$new" 2> /dev/null; then
printf "gen: cannot generate '%s': Permission denied\n" "$filename"; exit 1
Expand Down Expand Up @@ -204,7 +204,7 @@ get_args() {
if [[ "$OPTARG" =~ ^[0-9]*$ ]]; then
multi="$OPTARG"; suppress=true
else
printf "Provide a positive integer to generate multiple files.\n"
printf "gen: Provide a positive integer to generate multiple files.\n"
printf "Try 'gen -h' for more information.\n"; exit 1
fi
;;
Expand All @@ -219,7 +219,7 @@ get_args() {
if [[ -n "${1:-}" ]]; then
filename="$1"
else
printf "Must provide filename to generate.\n"
printf "gen: Must provide filename.\n"
printf "Try 'gen -h' for more information.\n"; exit 1
fi
}
Expand Down

0 comments on commit dad3b85

Please sign in to comment.