batdiff: Make --all default behavior for no arguments

This commit is contained in:
Ethan P 2020-10-28 19:40:35 -07:00
parent 4761b594a6
commit 0f6529a0d8
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -141,24 +141,23 @@ fi
# Validation:
# -----------------------------------------------------------------------------
# Handle no files.
if [[ "${#FILES[@]}" -eq 0 ]] && ! "$OPT_ALL_CHANGES"; then
print_error "no files provided"
exit 1
fi
# Handle too many files.
if [[ "${#FILES[@]}" -gt 2 ]]; then
print_error "too many files provided"
exit 1
fi
# Handle deprecated --all.
if "$OPT_ALL_CHANGES"; then
print_warning "argument --all is deprecated. Use '%s' instead" "$0"
fi
# -----------------------------------------------------------------------------
# Main:
# -----------------------------------------------------------------------------
main() {
if "$OPT_ALL_CHANGES"; then
if [[ "${#FILES[@]}" -eq 0 ]] || "$OPT_ALL_CHANGES"; then
local file
while read -r file; do
if [[ -f "$file" ]]; then