1*b30d1939SAndy Fiddaman#
2*b30d1939SAndy Fiddaman# CDDL HEADER START
3*b30d1939SAndy Fiddaman#
4*b30d1939SAndy Fiddaman# The contents of this file are subject to the terms of the
5*b30d1939SAndy Fiddaman# Common Development and Distribution License (the "License").
6*b30d1939SAndy Fiddaman# You may not use this file except in compliance with the License.
7*b30d1939SAndy Fiddaman#
8*b30d1939SAndy Fiddaman# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*b30d1939SAndy Fiddaman# or http://www.opensolaris.org/os/licensing.
10*b30d1939SAndy Fiddaman# See the License for the specific language governing permissions
11*b30d1939SAndy Fiddaman# and limitations under the License.
12*b30d1939SAndy Fiddaman#
13*b30d1939SAndy Fiddaman# When distributing Covered Code, include this CDDL HEADER in each
14*b30d1939SAndy Fiddaman# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*b30d1939SAndy Fiddaman# If applicable, add the following below this CDDL HEADER, with the
16*b30d1939SAndy Fiddaman# fields enclosed by brackets "[]" replaced with your own identifying
17*b30d1939SAndy Fiddaman# information: Portions Copyright [yyyy] [name of copyright owner]
18*b30d1939SAndy Fiddaman#
19*b30d1939SAndy Fiddaman# CDDL HEADER END
20*b30d1939SAndy Fiddaman#
21*b30d1939SAndy Fiddaman
22*b30d1939SAndy Fiddaman#
23*b30d1939SAndy Fiddaman# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*b30d1939SAndy Fiddaman# Use is subject to license terms.
25*b30d1939SAndy Fiddaman#
26*b30d1939SAndy Fiddaman
27*b30d1939SAndy Fiddaman#
28*b30d1939SAndy Fiddaman# name reference test #001
29*b30d1939SAndy Fiddaman#
30*b30d1939SAndy Fiddaman
31*b30d1939SAndy Fiddaman# test setup
32*b30d1939SAndy Fiddamanfunction err_exit
33*b30d1939SAndy Fiddaman{
34*b30d1939SAndy Fiddaman	print -u2 -n "\t"
35*b30d1939SAndy Fiddaman	print -u2 -r ${Command}[$1]: "${@:2}"
36*b30d1939SAndy Fiddaman	(( Errors++ ))
37*b30d1939SAndy Fiddaman}
38*b30d1939SAndy Fiddamanalias err_exit='err_exit $LINENO'
39*b30d1939SAndy Fiddaman
40*b30d1939SAndy Fiddamanset -o nounset
41*b30d1939SAndy FiddamanCommand=${0##*/}
42*b30d1939SAndy Fiddamaninteger Errors=0
43*b30d1939SAndy Fiddaman
44*b30d1939SAndy Fiddaman
45*b30d1939SAndy Fiddamanfunction function2
46*b30d1939SAndy Fiddaman{
47*b30d1939SAndy Fiddaman	nameref v=$1
48*b30d1939SAndy Fiddaman
49*b30d1939SAndy Fiddaman	v.x=19
50*b30d1939SAndy Fiddaman	v.y=20
51*b30d1939SAndy Fiddaman}
52*b30d1939SAndy Fiddaman
53*b30d1939SAndy Fiddamanfunction function1
54*b30d1939SAndy Fiddaman{
55*b30d1939SAndy Fiddaman	typeset compound_var=()
56*b30d1939SAndy Fiddaman
57*b30d1939SAndy Fiddaman	function2 compound_var
58*b30d1939SAndy Fiddaman
59*b30d1939SAndy Fiddaman	printf "x=%d, y=%d\n" compound_var.x compound_var.y
60*b30d1939SAndy Fiddaman}
61*b30d1939SAndy Fiddaman
62*b30d1939SAndy Fiddamanx="$(function1)"
63*b30d1939SAndy Fiddaman
64*b30d1939SAndy Fiddaman[[ "$x" != 'x=19, y=20' ]] && err_exit "expected 'x=19, y=20', got '${x}'"
65*b30d1939SAndy Fiddaman
66*b30d1939SAndy Fiddaman
67*b30d1939SAndy Fiddaman# tests done
68*b30d1939SAndy Fiddamanexit $((Errors))
69