File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ function stack_size
99
99
return 1
100
100
fi
101
101
# TODO: revise the eval below to eliminate the need for this pop/push
102
- # sequene, which is a workaround to prevent an error that occurs with
103
- # if the stack is new and has not been the target of a stack_push.
102
+ # sequene, which is a workaround to prevent an error that occurs with
103
+ # if the stack is new and has not been the target of a stack_push.
104
104
stack_push $1 __push_junk
105
105
stack_pop $1 __pop_trash
106
106
eval " $2 " =' $' " {#_stack_$1 [*]}"
@@ -112,7 +112,7 @@ function no_such_stack
112
112
stack_exists " $1 "
113
113
ret=$?
114
114
declare -i x
115
- let x=" 1-$ret "
115
+ let x=" 1-$ret " || true
116
116
return $x
117
117
}
118
118
@@ -183,8 +183,7 @@ function stack_print
183
183
184
184
while (( _i > 0 ))
185
185
do
186
- (( _i = _i - 1 )) || true
187
- eval ' e=$' " {_stack_$1 [$_i ]}"
186
+ eval ' e=$' " {_stack_$1 [$(( -- _i)) ]}" # pre-decrement
188
187
# shellcheck disable=SC2154
189
188
tmp=" $tmp $e "
190
189
done
@@ -210,13 +209,8 @@ function stack_new
210
209
return 1
211
210
fi
212
211
213
- if [[ $( uname) == " Darwin" ]]; then
214
- eval " declare -ag _stack_$1 " >& /dev/null || true
215
- eval " declare -ig _stack_$1 _i" >& /dev/null || true
216
- else
217
- eval " declare -ag _stack_$1 " >& /dev/null
218
- eval " declare -ig _stack_$1 _i" >& /dev/null
219
- fi
212
+ eval " _stack_$1 =()"
213
+ eval " _stack_$1 _i=0"
220
214
221
215
variableName=" _stack_$1 _i"
222
216
variableVal=" 0"
You can’t perform that action at this time.
0 commit comments