summaryrefslogtreecommitdiffstats
path: root/urldecode
blob: 19df702bb8647acbc0ec2ffdb2bb383a582bd419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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