Browse files

fix array pop with 3+ elements

  • Loading branch information...
1 parent 45ae83a commit eb490c8ceee1582a57d84a6e4341cf1467074bf7 @mpapis mpapis committed Aug 28, 2012
Showing with 15 additions and 10 deletions.
  1. +14 −9 core/internal/shell/array/array_comment_test.sh
  2. +1 −1 core/internal/shell/array/functions
View
23 core/internal/shell/array/array_comment_test.sh
@@ -6,12 +6,17 @@ typeset -ga arr1
typeset var1
arr1=()
-__sm.array.length arr1 # match=/^0$/
-__sm.array.push arr1 a # status=0
-__sm.array.length arr1 # match=/^1$/
-__sm.array.push arr1 b # status=0
-__sm.array.length arr1 # match=/^2$/
-__sm.array.pop arr1 # match=/^b$/; status=0
-__sm.array.length arr1 # match=/^1$/
-__sm.array.pop arr1 # match=/^a$/; status=0
-__sm.array.length arr1 # match=/^0$/
+: push-pop-length test
+__sm.array.length arr1 # match=/^0$/
+__sm.array.push arr1 a # status=0
+__sm.array.length arr1 # match=/^1$/
+__sm.array.push arr1 b # status=0
+__sm.array.length arr1 # match=/^2$/
+__sm.array.push arr1 "c d" # status=0
+__sm.array.length arr1 # match=/^3$/
+__sm.array.pop arr1 # match=/^c d$/; status=0
+__sm.array.length arr1 # match=/^2$/
+__sm.array.pop arr1 # match=/^b$/; status=0
+__sm.array.length arr1 # match=/^1$/
+__sm.array.pop arr1 # match=/^a$/; status=0
+__sm.array.length arr1 # match=/^0$/
View
2 core/internal/shell/array/functions
@@ -112,7 +112,7 @@ __sm.array.pop()
eval "echo \${${_name}[-1]}"
fi
- eval "if (( \${#${_name}[@]} == 1 )) ; then ${_name}=() ; else ${_name}=( \"\${${_name}[1,-2]}\" ) ; fi"
+ eval "if (( \${#${_name}[@]} == 1 )) ; then ${_name}=() ; else ${_name}=( \${${_name}[1,-2]} ) ; fi"
}
__sm.array.shift()

0 comments on commit eb490c8

Please sign in to comment.