mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2025-02-19 16:24:44 +02:00
Fix stashing aliases with a space in double quotes
This commit is contained in:
parent
f5951dd0cf
commit
4069af9cd0
@ -108,6 +108,7 @@ function stash() {
|
|||||||
local alias_def="$(eval alias $stash_which 2>/dev/null)"
|
local alias_def="$(eval alias $stash_which 2>/dev/null)"
|
||||||
if [[ -n $alias_def ]]; then
|
if [[ -n $alias_def ]]; then
|
||||||
alias_def=${alias_def#alias }
|
alias_def=${alias_def#alias }
|
||||||
|
alias_def=$(echo "$alias_def" | sed 's/"/\\&/g') # Escape double quotes
|
||||||
eval "__varstash_alias__$stash_name=\"$alias_def\""
|
eval "__varstash_alias__$stash_name=\"$alias_def\""
|
||||||
local stashed=1
|
local stashed=1
|
||||||
fi
|
fi
|
||||||
|
@ -13,9 +13,9 @@ Setup test environment.
|
|||||||
|
|
||||||
Aliases should be stashed.
|
Aliases should be stashed.
|
||||||
|
|
||||||
$ alias some_alias="echo ORIG_ALIAS"
|
$ alias some_alias='echo "ORIG ALIAS"'
|
||||||
$ some_alias
|
$ some_alias
|
||||||
ORIG_ALIAS
|
ORIG ALIAS
|
||||||
$ cd .
|
$ cd .
|
||||||
ENTER
|
ENTER
|
||||||
$ some_alias
|
$ some_alias
|
||||||
@ -23,13 +23,13 @@ Aliases should be stashed.
|
|||||||
$ cd ..
|
$ cd ..
|
||||||
LEAVE
|
LEAVE
|
||||||
$ some_alias
|
$ some_alias
|
||||||
ORIG_ALIAS
|
ORIG ALIAS
|
||||||
|
|
||||||
Aliases should be stashed, if there are also environment variables.
|
Aliases should be stashed, if there are also environment variables.
|
||||||
|
|
||||||
$ some_alias=ENV_VAR
|
$ some_alias=ENV_VAR
|
||||||
$ some_alias
|
$ some_alias
|
||||||
ORIG_ALIAS
|
ORIG ALIAS
|
||||||
$ cd sub
|
$ cd sub
|
||||||
ENTER
|
ENTER
|
||||||
$ type -w some_alias
|
$ type -w some_alias
|
||||||
|
Loading…
x
Reference in New Issue
Block a user