mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
add __fish_urlencode function which URL-escapes stdin
This commit is contained in:
parent
8159f55243
commit
04c0ac9ee8
1 changed files with 9 additions and 0 deletions
9
share/functions/__fish_urlencode.fish
Normal file
9
share/functions/__fish_urlencode.fish
Normal file
|
@ -0,0 +1,9 @@
|
|||
function __fish_urlencode --description "URL-encode stdin"
|
||||
while read f
|
||||
set lines (echo "$f" | sed -E -e 's/./\n\\0/g;/^$/d;s/\n//')
|
||||
if [ (count $lines) -gt 0 ]
|
||||
printf '%%%02x' "'"$lines"'" | sed -e 's/%2[fF]/\//g';
|
||||
end
|
||||
end
|
||||
echo
|
||||
end
|
Loading…
Reference in a new issue