4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # This test checks whether "typeset -m" correctly moves local variables
29 # into a global variable tree.
31 # This was reported as CR #XXXXXXXX ("XXXX"):
40 print
-u2 -r ${Command}[$1]: "${@:2}"
44 alias err_exit
='err_exit $LINENO'
49 typeset
-C tree1 tree2
51 # add node to tree which uses "typeset -m" to move a local variable
52 # into tree1.subtree["a_node"]
60 # move local note into the array
62 typeset
-m tr.subtree
["a_node"]=node
66 # Alternative version which uses "nameref" instead of "typeset -m"
71 nameref node
=tr.subtree
["a_node"]
80 [[ "${tree1.subtree["a_node"].one}" == "hello" ]] || err_exit
"expected tree1.subtree[\"a_node\"].one == 'hello', got ${tree1.subtree["a_node"].one}"
81 [[ "${tree1.subtree["a_node"].two}" == "world" ]] || err_exit
"expected tree1.subtree[\"a_node\"].two == 'world', got ${tree1.subtree["a_node"].two}"
82 [[ "${tree1}" == "${tree2}" ]] || err_exit
"tree1 and tree2 differ:$'\n'"