Skip to content

Commit 77a6735

Browse files
committed
fix 'ask' bug
1 parent a9a2d01 commit 77a6735

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

bashew.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ copy_and_replace() {
8181
local input="$1"
8282
local output="$2"
8383

84+
if [[ ! -f "$input" ]] ; then
85+
return 0
86+
fi
8487
awk \
8588
-v author_fullname="$author_fullname" \
8689
-v author_username="$author_username" \
@@ -449,17 +452,15 @@ confirm() {
449452
}
450453

451454
ask() {
452-
# $1 = variable name
453-
# $2 = question
454-
# $3 = default value
455-
# not using read -i because that doesn't work on MacOS
455+
# $1 = question
456+
# $2 = default value
456457
local ANSWER
457458
if [[ -n "${2:-}" ]] ; then
458459
read -r -p "$1 ($2) > " ANSWER
459460
else
460461
read -r -p "$1 > " ANSWER
461462
fi
462-
echo "$ANSWER"
463+
[[ -n "$ANSWER" ]] && echo "$ANSWER" || echo "${2:-}"
463464
}
464465

465466
trap "die \"ERROR \$? after \$SECONDS seconds \n\

0 commit comments

Comments
 (0)