Improve edge cases for handling empty inputs
This commit is contained in:
parent
a0fdbe0149
commit
005638bef4
2 changed files with 9 additions and 4 deletions
|
@ -47,8 +47,7 @@ file_merge_tree() {
|
||||||
local prompt_verb="In configuration only"
|
local prompt_verb="In configuration only"
|
||||||
local prompt_options="Copy to system"
|
local prompt_options="Copy to system"
|
||||||
fi
|
fi
|
||||||
strategy="$(ask "$prompt_verb: $(tildify "$absolute_path")" "$prompt_options")" ||
|
strategy="$(ask "$prompt_verb: $(tildify "$absolute_path")" "$prompt_options")"
|
||||||
file_merge_tree "$base_files"
|
|
||||||
log debug "[merge_tree] Chosen strategy: $strategy"
|
log debug "[merge_tree] Chosen strategy: $strategy"
|
||||||
|
|
||||||
if [ "$strategy" -eq 0 ]; then
|
if [ "$strategy" -eq 0 ]; then
|
||||||
|
@ -65,6 +64,7 @@ file_merge_tree() {
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
log user 'Invalid choice'
|
log user 'Invalid choice'
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -76,10 +76,15 @@ ask() {
|
||||||
read -r read_answer
|
read -r read_answer
|
||||||
answer="$(echo "$read_answer" | xargs)"
|
answer="$(echo "$read_answer" | xargs)"
|
||||||
|
|
||||||
if [ "$answer" -ge 0 ] 2> /dev/null && [ "$answer" -le $options_count ]; then
|
if [ -z "$answer" ]; then
|
||||||
|
log info "[ask] Invalid choice"
|
||||||
|
echo -1
|
||||||
|
return 1
|
||||||
|
elif [ "$answer" -ge 0 ] 2> /dev/null && [ "$answer" -le $options_count ]; then
|
||||||
echo "$answer"
|
echo "$answer"
|
||||||
else
|
else
|
||||||
log debug "[ask] Invalid choice"
|
log info "[ask] Invalid choice"
|
||||||
|
echo -1
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue