From a470f9309feed13fac04161d5b41de0bff402d32 Mon Sep 17 00:00:00 2001 From: Samuel Henrique Date: Tue, 11 Feb 2025 22:03:56 +0000 Subject: [PATCH] Allow -o and -O to be used without whitespaces (e.g.: -oNAME) Thanks to MithicSpirit for the suggestion. Closes #42 --- tests/tests.sh | 8 ++++++++ wcurl | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tests/tests.sh b/tests/tests.sh index de76396..2a64a8c 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -132,6 +132,14 @@ testOutputFileName() assertContains "Verify whether 'wcurl' correctly sets a custom output filename" "${ret}" 'test filename' } +testOutputFileNameWithoutSpaces() +{ + url='example.com' + ret=$(${WCURL_CMD} -o"test filename" ${url} 2>&1) + assertContains "Verify whether 'wcurl' correctly sets --output" "${ret}" '--output' + assertContains "Verify whether 'wcurl' correctly sets --output with the correct filename" "${ret}" 'test filename' +} + testOutputFileNameRepeatedOption() { url='example.com' diff --git a/wcurl b/wcurl index 365db03..ba2ea4a 100755 --- a/wcurl +++ b/wcurl @@ -275,6 +275,12 @@ while [ -n "${1-}" ]; do OUTPUT_PATH="${1}" ;; + -o*|-O*) + opt=$(printf "%s\n" "${1}" | sed 's/^-[oO]//') + HAS_USER_SET_OUTPUT="true" + OUTPUT_PATH="${opt}" + ;; + --no-decode-filename) DECODE_FILENAME="false" ;;