summaryrefslogtreecommitdiffstats
path: root/urldecode
diff options
context:
space:
mode:
Diffstat (limited to 'urldecode')
-rwxr-xr-xurldecode16
1 files changed, 16 insertions, 0 deletions
diff --git a/urldecode b/urldecode
new file mode 100755
index 0000000..19df702
--- /dev/null
+++ b/urldecode
@@ -0,0 +1,16 @@
+#!/bin/bash
+arg="$1"
+i="0"
+while [ "$i" -lt ${#arg} ]; do
+ c0=${arg:$i:1}
+ if [ "x$c0" = "x%" ]; then
+ c1=${arg:$((i+1)):1}
+ c2=${arg:$((i+2)):1}
+ printf "\x$c1$c2"
+ i=$((i+3))
+ else
+ echo -n "$c0"
+ i=$((i+1))
+ fi
+done
+