blob: 47344554e5d5aee991f38628841d227e46af9b5d [file] [log] [blame]
Jari Aaltod166f041997-06-05 14:59:13 +00001minus=-
2
3# standard input
4fd=0
5
6exec 3<&$fd
7
8read line <&3
9echo from stdin: $line
10
11# close fd 3
12exec 3<&${minus}
13
14# should give `bad fd', but exact error messages vary
15# read line <&3
16
17# standard output
18fd=1
19
20exec 4>&$fd
21
22echo to stdout >&4
23
24exec 4>&$minus
25
26# should give `bad fd', but exact error messages vary
27# echo to stdout >&4
28
29unset fd
30
31# these are ambiguous redirects
32exec 3<&$fd
33exec 4>&$fd
34
35exec 3>&1 4>&2
36
37exec >&/tmp/err-and-out
38echo to stdout
39echo to stderr >&2
40
41exec 1>&3 2>&4
42echo /tmp/err-and-out:
43cat /tmp/err-and-out
44
45rm /tmp/err-and-out
46
47fd=/tmp/err-and-out
48exec >&$fd
49echo to stdout
50echo to stderr >&2
51
52exec 1>&3 2>&4
53echo /tmp/err-and-out:
54cat /tmp/err-and-out
55
56rm /tmp/err-and-out