Skip to content

Instantly share code, notes, and snippets.

@aplund
Created April 24, 2017 01:36
Show Gist options
  • Save aplund/c650ecdf90a29c63508cb1f0d4aa0dc9 to your computer and use it in GitHub Desktop.
Save aplund/c650ecdf90a29c63508cb1f0d4aa0dc9 to your computer and use it in GitHub Desktop.
function decode {
target=0
len=${#1}
outstr=""
while [ $target -lt $len ]
do
if [ ${1:$target:1} != '%' ]; then
outstr=$outstr${1:$target:1}
target=$(($target + 1))
elif [ ${1:$target:2} == '%f' ]; then
outstr=$outstr"/"
target=$(($target + 2))
else
outstr=$outstr${1:$target+1:1}
target=$(($target + 2))
fi
done
echo $outstr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment