diff options
author | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2014-11-20 13:53:24 +0800 |
---|---|---|
committer | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2014-11-20 13:53:24 +0800 |
commit | 0abdf9eeffa5cd7d1045ac42ed67a8c0113e1f66 (patch) | |
tree | 2d13c0ddbffb62cd09b708280e13d09af863ec8e /share/functions/__fish_urlencode.fish | |
parent | 8e8549ef7ace4f2270017ecd26f9036f5cd1ec6a (diff) |
__fish_urlencode: rework to behave properly on BSD/OS X
Work on #68.
Diffstat (limited to 'share/functions/__fish_urlencode.fish')
-rw-r--r-- | share/functions/__fish_urlencode.fish | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/share/functions/__fish_urlencode.fish b/share/functions/__fish_urlencode.fish index ebf5ba5d..ab13beaa 100644 --- a/share/functions/__fish_urlencode.fish +++ b/share/functions/__fish_urlencode.fish @@ -1,9 +1,10 @@ function __fish_urlencode --description "URL-encode stdin" - while read f - set lines (echo "$f" | sed -E -e 's/./\n\\0/g;/^$/d;s/\n//') + set -l IFS '' + set -l output + while read --array --local lines if [ (count $lines) -gt 0 ] - printf '%%%02x' "'"$lines"'" | sed -e 's/%2[fF]/\//g'; + set output $output (printf '%%%02x' "'"$lines"'" | sed -e 's/%2[fF]/\//g') end end - echo + echo -s $output end |