diff options
Diffstat (limited to 'usr/src/lib/libshell/common/scripts/simplefiletree1.sh')
-rw-r--r-- | usr/src/lib/libshell/common/scripts/simplefiletree1.sh | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr/src/lib/libshell/common/scripts/simplefiletree1.sh b/usr/src/lib/libshell/common/scripts/simplefiletree1.sh index 5b79aae8f8..d2308394cf 100644 --- a/usr/src/lib/libshell/common/scripts/simplefiletree1.sh +++ b/usr/src/lib/libshell/common/scripts/simplefiletree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -68,14 +67,18 @@ function add_file_to_tree nodepath="${treename}" for (( i=0 ; i < (${#pe[@]}-1) ; i++ )) ; do nameref x="${nodepath}" - [[ ! -v x.node ]] && compound -A x.nodes + + # [[ -v ]] does not work for arrays because [[ -v ar ]] + # is equal to [[ -v ar[0] ]]. In this case we can + # use the output of typeset +p x.nodes + [[ "${ typeset +p x.nodes ; }" == "" ]] && compound -A x.nodes nodepath+=".nodes[${pe[i]}]" done # insert element nameref node="${nodepath}" - [[ ! -v node.elements ]] && typeset -a node.elements + [[ "${ typeset +p node.elements ; }" == "" ]] && typeset -a node.elements node.elements+=( "${pe[i]}" ) return 0 |