diff --git a/example b/example index 1c79f80..ef515e4 100755 --- a/example +++ b/example @@ -48,8 +48,19 @@ ensure_command_installed() { fi } -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" +percent_encode() { + str="$1" + len=$(printf "%s" "$str" | wc -c) + i=1 + while [ $i -le $len ] + do + char=$(printf "%s" "$str" | cut -c $i) + printf '%%%02X' "'$char" + i=$((i+1)) + done +} + +DENO_VERSION_RANGE_URL_ENCODED="$(percent_encode "${DENO_VERSION_RANGE}")" DEFAULT_DENO="$(command -v deno || true)" get_largest_usable_tmpfs() { diff --git a/example-piped b/example-piped index 2d962b6..3dd9bb9 100755 --- a/example-piped +++ b/example-piped @@ -48,7 +48,19 @@ ensure_command_installed() { fi } -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" +percent_encode() { + str="$1" + len=$(printf "%s" "$str" | wc -c) + i=1 + while [ $i -le $len ] + do + char=$(printf "%s" "$str" | cut -c $i) + printf '%%%02X' "'$char" + i=$((i+1)) + done +} + +DENO_VERSION_RANGE_URL_ENCODED="$(percent_encode "${DENO_VERSION_RANGE}")" DEFAULT_DENO="$(command -v deno || true)" get_largest_usable_tmpfs() { diff --git a/example-piped.ts b/example-piped.ts index 2d962b6..3dd9bb9 100755 --- a/example-piped.ts +++ b/example-piped.ts @@ -48,7 +48,19 @@ ensure_command_installed() { fi } -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" +percent_encode() { + str="$1" + len=$(printf "%s" "$str" | wc -c) + i=1 + while [ $i -le $len ] + do + char=$(printf "%s" "$str" | cut -c $i) + printf '%%%02X' "'$char" + i=$((i+1)) + done +} + +DENO_VERSION_RANGE_URL_ENCODED="$(percent_encode "${DENO_VERSION_RANGE}")" DEFAULT_DENO="$(command -v deno || true)" get_largest_usable_tmpfs() { diff --git a/example.ts b/example.ts index 1c79f80..ef515e4 100755 --- a/example.ts +++ b/example.ts @@ -48,8 +48,19 @@ ensure_command_installed() { fi } -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" +percent_encode() { + str="$1" + len=$(printf "%s" "$str" | wc -c) + i=1 + while [ $i -le $len ] + do + char=$(printf "%s" "$str" | cut -c $i) + printf '%%%02X' "'$char" + i=$((i+1)) + done +} + +DENO_VERSION_RANGE_URL_ENCODED="$(percent_encode "${DENO_VERSION_RANGE}")" DEFAULT_DENO="$(command -v deno || true)" get_largest_usable_tmpfs() { diff --git a/src/deno-shebang-piped.sh b/src/deno-shebang-piped.sh index de84eed..059af58 100755 --- a/src/deno-shebang-piped.sh +++ b/src/deno-shebang-piped.sh @@ -48,7 +48,19 @@ ensure_command_installed() { fi } -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" +percent_encode() { + str="$1" + len=$(printf "%s" "$str" | wc -c) + i=1 + while [ $i -le $len ] + do + char=$(printf "%s" "$str" | cut -c $i) + printf '%%%02X' "'$char" + i=$((i+1)) + done +} + +DENO_VERSION_RANGE_URL_ENCODED="$(percent_encode "${DENO_VERSION_RANGE}")" DEFAULT_DENO="$(command -v deno || true)" get_largest_usable_tmpfs() { diff --git a/src/deno-shebang.sh b/src/deno-shebang.sh index 429f43d..955b7b9 100755 --- a/src/deno-shebang.sh +++ b/src/deno-shebang.sh @@ -48,7 +48,19 @@ ensure_command_installed() { fi } -DENO_VERSION_RANGE_URL_ENCODED="$(printf "%s" "${DENO_VERSION_RANGE}" | xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g')" +percent_encode() { + str="$1" + len=$(printf "%s" "$str" | wc -c) + i=1 + while [ $i -le $len ] + do + char=$(printf "%s" "$str" | cut -c $i) + printf '%%%02X' "'$char" + i=$((i+1)) + done +} + +DENO_VERSION_RANGE_URL_ENCODED="$(percent_encode "${DENO_VERSION_RANGE}")" DEFAULT_DENO="$(command -v deno || true)" get_largest_usable_tmpfs() {