#!/bin/bash
read foo
if [[ $* == -d ]]
then
perl -MURI::Escape -e 'print uri_unescape($ARGV[0])' $foo
else
perl -MURI::Escape -e 'print uri_escape($ARGV[0])' $foo
fi