18c837b136a9591117ef059eb8266c490d5eeee1

Author
Erin Schlarb <erin-dev@ninetailed.ninja>
Committer
GitHub <noreply@github.com>
Date

Message

fix(dirhistory): run properly if `ksh_arrays` is set (#11630)

Diff

 1diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
 2index 7021fc03a34173f93e5155d038538cc25901331a..8d67c61886430f7b613b978de5ebd24351883f4d 100644
 3--- a/plugins/dirhistory/dirhistory.plugin.zsh
 4+++ b/plugins/dirhistory/dirhistory.plugin.zsh
 5@@ -19,15 +19,17 @@ export DIRHISTORY_SIZE=30
 6 # Returns the element if the array was not empty,
 7 # otherwise returns empty string.
 8 function pop_past() {
 9-  typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
10+  setopt localoptions no_ksh_arrays
11   if [[ $#dirhistory_past -gt 0 ]]; then
12+    typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
13     dirhistory_past[$#dirhistory_past]=()
14   fi
15 }
16 
17 function pop_future() {
18-  typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
19+  setopt localoptions no_ksh_arrays
20   if [[ $#dirhistory_future -gt 0 ]]; then
21+    typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
22     dirhistory_future[$#dirhistory_future]=()
23   fi
24 }
25@@ -35,6 +37,7 @@ function pop_future() {
26 # Push a new element onto the end of dirhistory_past. If the size of the array
27 # is >= DIRHISTORY_SIZE, the array is shifted
28 function push_past() {
29+  setopt localoptions no_ksh_arrays
30   if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
31     shift dirhistory_past
32   fi
33@@ -44,6 +47,7 @@ function push_past() {
34 }
35 
36 function push_future() {
37+  setopt localoptions no_ksh_arrays
38   if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
39     shift dirhistory_future
40   fi