diff --git a/share/functions/__fish_urlencode.fish b/share/functions/__fish_urlencode.fish index ebf5ba5df..ab13beaa6 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