You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One way to reimplement how abbreviations are stored requires a method to convert arbitrary strings to/from valid var names. See issue #4048. This need also recently arose in the context of git completions. See issue #4147. It turns out that converting strings to valid var names is only moderately difficult using fish script:
function encode_to_var
set -l orig_str "$argv"
set -l new_str ''
for letter in (string split '' $orig_str)
if string match -qr '\w' -- $letter
if test $letter = '_'
set new_str {$new_str}__
else
set new_str "$new_str$letter"
end
else
echo -n $letter | begin
set -lx LC_ALL C
read -lz utf8
# string split '' -- $utf8 | od -tx1x >&2
printf '_%02X' \'(string split '' -- $utf8)
end | read letter
set new_str {$new_str}$letter
end
end
echo $new_str
end
Unfortunately that is ugly and slow. Doing the inverse operation in fish script will also be extremely difficult. So this issue is to track augmenting the string escape builtin by adding a --style=xxx flag. Where xxx would be var or url. The latter would allow us to eliminate the __fish_urlencode function. For completeness we would also allow the style to be script to explicitly request the current default behavior.
Note that we'll also need a string unescape that also supports the --style=xxx flag. But we'll do that work under issue #3543 since we don't currently have that string subcommand.
The text was updated successfully, but these errors were encountered:
One way to reimplement how abbreviations are stored requires a method to convert arbitrary strings to/from valid var names. See issue #4048. This need also recently arose in the context of git completions. See issue #4147. It turns out that converting strings to valid var names is only moderately difficult using fish script:
Unfortunately that is ugly and slow. Doing the inverse operation in fish script will also be extremely difficult. So this issue is to track augmenting the
string escape
builtin by adding a--style=xxx
flag. Wherexxx
would bevar
orurl
. The latter would allow us to eliminate the__fish_urlencode
function. For completeness we would also allow the style to bescript
to explicitly request the current default behavior.Note that we'll also need a
string unescape
that also supports the--style=xxx
flag. But we'll do that work under issue #3543 since we don't currently have thatstring
subcommand.The text was updated successfully, but these errors were encountered: