diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-07-20 15:24:07 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-07-20 15:24:07 +0200 |
commit | 5bb9c57fdbfe6ee69c0ffaad52b9d4259a6b97f5 (patch) | |
tree | c5e0465d81ef97516888c173e9b9ab75b515ba9f /urldecode | |
parent | 934c2f85fa9c3b679d5c91bf8fc09272a2bec537 (diff) | |
download | bin-5bb9c57fdbfe6ee69c0ffaad52b9d4259a6b97f5.tar.gz bin-5bb9c57fdbfe6ee69c0ffaad52b9d4259a6b97f5.tar.xz |
urldecode: rewrite in php
Faster than pure bash and simple enough.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'urldecode')
-rwxr-xr-x | urldecode | 24 |
1 files changed, 9 insertions, 15 deletions
@@ -1,16 +1,10 @@ -#!/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 +#!/usr/bin/php +<?php +if (count($argv) == 0) { + echo urldecode(file_get_contents("php://stdin")); +} else { + foreach ($argv as $arg) { + echo urldecode(file_get_contents($arg)); + } +} |