Skip to content

Instantly share code, notes, and snippets.

@rcknr
Created January 8, 2013 21:39
Show Gist options
  • Save rcknr/4488234 to your computer and use it in GitHub Desktop.
Save rcknr/4488234 to your computer and use it in GitHub Desktop.
Simplistic URL encoding for Busybox shell.
#!/bin/sh
echo "$@" | awk -v ORS="" '{ gsub(/./,"&\n") ; print }' | while read l;
do
case "$l" in
[-_.~a-zA-Z0-9] ) echo -n ${l} ;;
"" ) echo -n %20 ;;
* ) printf '%%%02X' "'$l"
esac
done
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment