Skip to content

Commit

Permalink
Replace external tools with fish builtins
Browse files Browse the repository at this point in the history
Fix issue #22
Fix issue #21

Replace use of external tools (grep and perl) with fish builtin string.
  • Loading branch information
AbysmalBiscuit authored and gregorias committed Apr 30, 2022
1 parent 9a16edd commit 3ce5c57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conf.d/__fasd_run.fish
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function __fasd_expand_vars -d "Expands only the first occurance of a variable in the passed string without evaluating the string"
set -lx vars (echo -n $argv | grep -oP '(?!\\\\)\$\K([A-z_][A-z0-9_]*?)([^A-z0-9_]|\b|\n)' | perl -pe 's/(.+?)(?:[^A-z0-9_]|\b)$/\1\n/' | sort -u)
set -lx vars (string match -a -r '(?!\\\\)\$\K([A-z_][A-z0-9_]*?)(?:[^A-z0-9_]|\b|\n)' "$argv" | string replace -r '(.+?)(?:[^A-z0-9_]|\b)$' '$1' | sort -u)
for var in $vars
# Only replace if the variable is defined
if set -q $var
# Replacing the variable once is enough
set argv (string replace -r '([^\\\\]|\b)\$'"$var" '$1'"$$var" "$argv")
set argv (string replace -r '([^\\\\]|\b)\$'"$var" '${1}'"$$var" "$argv")
end
end
# The following pipe does the same thing as fasd --sanitize
Expand Down

0 comments on commit 3ce5c57

Please sign in to comment.