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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 24*b30d1939SAndy Fiddaman# 25*b30d1939SAndy Fiddaman 26*b30d1939SAndy Fiddaman# 27*b30d1939SAndy Fiddaman# Test whether CR #6754020 ("ksh93 does weird '[' expansion") has 28*b30d1939SAndy Fiddaman# been fixed. 29*b30d1939SAndy Fiddaman# 30*b30d1939SAndy Fiddaman# Quote from CR #6754020: 31*b30d1939SAndy Fiddaman# ---- snip ---- 32*b30d1939SAndy Fiddaman# The problem is that subprocess uses /bin/sh as the shell when it 33*b30d1939SAndy Fiddaman# spins off the process. As Brad demonstrated: 34*b30d1939SAndy Fiddaman# /bin/sh -c 'echo F[[O]' 35*b30d1939SAndy Fiddaman# F[[O][ 36*b30d1939SAndy Fiddaman# 37*b30d1939SAndy Fiddaman# In short, this bug only appears when run through the test suite, 38*b30d1939SAndy Fiddaman# or by people running /bin/sh who don't understand how their shell 39*b30d1939SAndy Fiddaman# treats special characters. 40*b30d1939SAndy Fiddaman# -- snip -- 41*b30d1939SAndy Fiddaman# 42*b30d1939SAndy Fiddaman# In this case ksh93 has a bug which causes "F[[O]" to be expanded 43*b30d1939SAndy Fiddaman# in a wrong way. 44*b30d1939SAndy Fiddaman# ---- snip ---- 45*b30d1939SAndy Fiddaman 46*b30d1939SAndy Fiddaman 47*b30d1939SAndy Fiddaman# test setup 48*b30d1939SAndy Fiddamanfunction err_exit 49*b30d1939SAndy Fiddaman{ 50*b30d1939SAndy Fiddaman print -u2 -n "\t" 51*b30d1939SAndy Fiddaman print -u2 -r ${Command}[$1]: "${@:2}" 52*b30d1939SAndy Fiddaman (( Errors < 127 && Errors++ )) 53*b30d1939SAndy Fiddaman} 54*b30d1939SAndy Fiddamanalias err_exit='err_exit $LINENO' 55*b30d1939SAndy Fiddaman 56*b30d1939SAndy Fiddamanset -o nounset 57*b30d1939SAndy FiddamanCommand=${0##*/} 58*b30d1939SAndy Fiddamaninteger Errors=0 59*b30d1939SAndy Fiddaman 60*b30d1939SAndy Fiddaman 61*b30d1939SAndy Fiddamantypeset s 62*b30d1939SAndy Fiddaman 63*b30d1939SAndy Fiddaman# test using "echo" 64*b30d1939SAndy Fiddamans="$(${SHELL} -c 'echo F[[O]')" 65*b30d1939SAndy Fiddaman[[ "$s" == 'F[[O]' ]] || err_exit "Expected 'F[[O]', got $s" 66*b30d1939SAndy Fiddaman 67*b30d1939SAndy Fiddamans="$(${SHELL} -c 'echo F[[[O]]')" 68*b30d1939SAndy Fiddaman[[ "$s" == 'F[[[O]]' ]] || err_exit "Expected 'F[[[O]]', got $s" 69*b30d1939SAndy Fiddaman 70*b30d1939SAndy Fiddaman 71*b30d1939SAndy Fiddaman# test using "print" 72*b30d1939SAndy Fiddamans="$(${SHELL} -c 'print F[[O]')" 73*b30d1939SAndy Fiddaman[[ "$s" == 'F[[O]' ]] || err_exit "Expected 'F[[O]', got $s" 74*b30d1939SAndy Fiddaman 75*b30d1939SAndy Fiddamans="$(${SHELL} -c 'print F[[[O]]')" 76*b30d1939SAndy Fiddaman[[ "$s" == 'F[[[O]]' ]] || err_exit "Expected 'F[[[O]]', got $s" 77*b30d1939SAndy Fiddaman 78*b30d1939SAndy Fiddaman 79*b30d1939SAndy Fiddaman# tests done 80*b30d1939SAndy Fiddamanexit $((Errors)) 81