Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/ksh93/tests/select.sh
1810 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1982-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# David Korn <[email protected]> #
18
# #
19
########################################################################
20
function err_exit
21
{
22
print -u2 -n "\t"
23
print -u2 -r ${Command}[$1]: "${@:2}"
24
let Errors+=1
25
}
26
alias err_exit='err_exit $LINENO'
27
28
Command=${0##*/}
29
integer Errors=0
30
31
tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
32
trap "cd /; rm -rf $tmp" EXIT
33
34
PS3='ABC '
35
36
cat > $tmp/1 <<\!
37
1) foo
38
2) bar
39
3) bam
40
!
41
42
select i in foo bar bam
43
do case $i in
44
foo) break;;
45
*) err_exit "select 1 not working"
46
break;;
47
esac
48
done 2> /dev/null <<!
49
1
50
!
51
52
unset i
53
select i in foo bar bam
54
do case $i in
55
foo) err_exit "select foo not working" 2>&3
56
break;;
57
*) if [[ $REPLY != foo ]]
58
then err_exit "select REPLY not correct" 2>&3
59
fi
60
( set -u; : $i ) || err_exit "select: i not set to null" 2>&3
61
break;;
62
esac
63
done 3>&2 2> $tmp/2 <<!
64
foo
65
!
66
67
exit $((Errors<125?Errors:125))
68
69