1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2025-02-16 15:04:43 +02:00

Fix stashing aliases with a space in double quotes

This commit is contained in:
Peter Toth 2024-06-21 01:04:08 +04:00
parent f5951dd0cf
commit 4069af9cd0
2 changed files with 5 additions and 4 deletions

View File

@ -108,6 +108,7 @@ function stash() {
local alias_def="$(eval alias $stash_which 2>/dev/null)"
if [[ -n $alias_def ]]; then
alias_def=${alias_def#alias }
alias_def=$(echo "$alias_def" | sed 's/"/\\&/g') # Escape double quotes
eval "__varstash_alias__$stash_name=\"$alias_def\""
local stashed=1
fi

View File

@ -13,9 +13,9 @@ Setup test environment.
Aliases should be stashed.
$ alias some_alias="echo ORIG_ALIAS"
$ alias some_alias='echo "ORIG ALIAS"'
$ some_alias
ORIG_ALIAS
ORIG ALIAS
$ cd .
ENTER
$ some_alias
@ -23,13 +23,13 @@ Aliases should be stashed.
$ cd ..
LEAVE
$ some_alias
ORIG_ALIAS
ORIG ALIAS
Aliases should be stashed, if there are also environment variables.
$ some_alias=ENV_VAR
$ some_alias
ORIG_ALIAS
ORIG ALIAS
$ cd sub
ENTER
$ type -w some_alias