Add mutual exclusion validation for conflict handling options
Ensure --force, --skip, --backup, --rename options are used exclusively to prevent ambiguous conflict resolution behavior. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,19 @@ while [[ $# -gt 0 ]]; do
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate mutual exclusion of conflict handling options
|
||||
CONFLICT_OPTS_COUNT=0
|
||||
[ "$FORCE" = true ] && CONFLICT_OPTS_COUNT=$((CONFLICT_OPTS_COUNT + 1))
|
||||
[ "$SKIP" = true ] && CONFLICT_OPTS_COUNT=$((CONFLICT_OPTS_COUNT + 1))
|
||||
[ "$BACKUP" = true ] && CONFLICT_OPTS_COUNT=$((CONFLICT_OPTS_COUNT + 1))
|
||||
[ "$RENAME" = true ] && CONFLICT_OPTS_COUNT=$((CONFLICT_OPTS_COUNT + 1))
|
||||
|
||||
if [ $CONFLICT_OPTS_COUNT -gt 1 ]; then
|
||||
echo "Error: Conflict handling options are mutually exclusive." >&2
|
||||
echo "Use only one of: --force, --skip, --backup, --rename" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check file path argument
|
||||
if [ -z "$FILE_PATH" ]; then
|
||||
echo "Usage: $0 <file_path> [subpath] [--force|--skip|--backup|--rename]" >&2
|
||||
|
||||
Reference in New Issue
Block a user