Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ jobs:
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y shellcheck devscripts
sudo apt-get install -y shellcheck devscripts shfmt

- name: Run shellcheck
run: shellcheck wcurl tests/*

- name: Run checkbashisms
run: checkbashisms wcurl tests/*

- name: Run shfmt
run: shfmt --func-next-line --space-redirects --case-indent --binary-next-line --indent 4 --posix --diff .

debian:
name: debian
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export PATH="${ROOTDIR}:${PATH}"

readonly WCURL_CMD="wcurl --dry-run "

oneTimeSetUp() {
oneTimeSetUp()
{
if ! assertContains "Check compatibility" "test" "test"; then
echo "Error: shunit2 version 2.1.8 or higher is required."
echo "Please install a compatible version of shunit2."
Expand Down
18 changes: 9 additions & 9 deletions wcurl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ sanitize()
is_subset_of()
{
case "${1}" in
*[!${2}]*|'') return 1;;
*[!${2}]* | '') return 1 ;;
esac
}

Expand All @@ -151,9 +151,9 @@ percent_decode()
decode_out="${decode_out}${decode_hex2}"
# Skip decoding if this is a control character (00-1F).
# Skip decoding if DECODE_FILENAME is not "true".
if is_subset_of "${decode_hex1}" "23456789abcdefABCDEF" && \
is_subset_of "${decode_hex2}" "0123456789abcdefABCDEF" && \
[ "${DECODE_FILENAME}" = "true" ]; then
if is_subset_of "${decode_hex1}" "23456789abcdefABCDEF" \
&& is_subset_of "${decode_hex2}" "0123456789abcdefABCDEF" \
&& [ "${DECODE_FILENAME}" = "true" ]; then
# Use printf to decode it into octal and then decode it to the final format.
decode_out="$(printf "%b" "\\$(printf %o "0x${decode_hex1}${decode_hex2}")")"
fi
Expand All @@ -171,7 +171,7 @@ get_url_filename()
# If what remains contains a slash, there's a path; return it percent-decoded.
case "${hostname_and_path}" in
# sed to remove everything preceding the last '/', e.g.: "example/something" becomes "something"
*/*) percent_decode "$(printf %s "${hostname_and_path}" | sed -e 's,^.*/,,')";;
*/*) percent_decode "$(printf %s "${hostname_and_path}" | sed -e 's,^.*/,,')" ;;
esac
# No slash means there was just a hostname and no path; return empty string.
}
Expand Down Expand Up @@ -268,13 +268,13 @@ while [ -n "${1-}" ]; do
OUTPUT_PATH="${opt}"
;;

-o|-O|--output)
-o | -O | --output)
shift
HAS_USER_SET_OUTPUT="true"
OUTPUT_PATH="${1}"
;;

-o*|-O*)
-o* | -O*)
opt=$(printf "%s\n" "${1}" | sed 's/^-[oO]//')
HAS_USER_SET_OUTPUT="true"
OUTPUT_PATH="${opt}"
Expand All @@ -284,12 +284,12 @@ while [ -n "${1-}" ]; do
DECODE_FILENAME="false"
;;

-h|--help)
-h | --help)
usage
exit 0
;;

-V|--version)
-V | --version)
print_version
exit 0
;;
Expand Down
Loading