From 3b5fdc3fb0c4c7cbcfc1a3de273ce3cbfec437b4 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 28 Jun 2017 23:21:33 +0200 Subject: [PATCH] git completions: Fix aliases with weird characters A use for the new `string escape --style=var`. Fixes #4147. --- share/completions/git.fish | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index a09332afb..2fe65eb44 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -144,7 +144,8 @@ end # This is because alias:command is an n:1 mapping (an alias can only have one corresponding command, # but a command can be aliased multiple times) git config -z --get-regexp 'alias\..*' | while read -lz alias command _ - set alias (string replace 'alias.' '' -- $alias) + # Git aliases can contain chars that variable names can't - escape them. + set alias (string replace 'alias.' '' -- $alias | string escape --style=var) set -g __fish_git_alias_$alias $command end @@ -156,7 +157,7 @@ function __fish_git_using_command and return 0 # Check aliases. - set -l varname __fish_git_alias_$cmd + set -l varname __fish_git_alias_(string escape --style=var -- $cmd) contains -- "$$varname" $argv and return 0 return 1