fishgretel / fasd

Plugin for fish-shell to integrate fasd
https://github.com/fisherman/fisherman
Other
58 stars 19 forks source link

Fix __fasd_run.fish eval bug #20

Closed AbysmalBiscuit closed 3 years ago

AbysmalBiscuit commented 3 years ago

This PR fixes issues #16, #17, and #18.

The fix adds a function that expands variables without evaluating the passed string in the __fasd_run function.

This allows constructs such as redirections, loops, glob expansions, etc... to not be affected by the fish_postexec hook. This lets fasd take account of relative directories.

The following is an example of save variable expansion when a for loop is passed:

$ set folders foo bar baz
$ __fasd_expand_vars 'for f in $folders; echo \$folders; cd $f; cd $abc; echo $folders; end'
for
f
in
foo
bar
baz
echo
\$folders
cd
f
cd
abc
echo
folders
end

Variables are also expanded correctly if the input is multi-line:

$ set folders foo bar baz
$ __fasd_expand_vars 'for f in $folders
  echo \$folders
  cd $f
  cd $abc
  echo $folders
end'
for
f
in
foo
bar
baz
echo
\$folders
cd
f
cd
abc
echo
folders
end