blob: 136d87400b4e0e57b2bd1635119158549139a1a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2010 AT&T Intellectual Property #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# http://www.opensource.org/licenses/cpl1.0.txt #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
function err_exit
{
print -u2 -n "\t"
print -u2 -r ${Command}[$1]: "${@:2}"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
Command=${0##*/}
integer Errors=0
tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
trap "cd /; rm -rf $tmp" EXIT
PS3='ABC '
cat > $tmp/1 <<\!
1) foo
2) bar
3) bam
!
select i in foo bar bam
do case $i in
foo) break;;
*) err_exit "select 1 not working"
break;;
esac
done 2> /dev/null <<!
1
!
unset i
select i in foo bar bam
do case $i in
foo) err_exit "select foo not working" 2>&3
break;;
*) if [[ $REPLY != foo ]]
then err_exit "select REPLY not correct" 2>&3
fi
( set -u; : $i ) || err_exit "select: i not set to null" 2>&3
break;;
esac
done 3>&2 2> $tmp/2 <<!
foo
!
exit $((Errors))
|