~sircmpwn/ctools

ref: 16cab053e27d4a7046c005b5becae9b0564d8211 ctools/test/tty -rwxr-xr-x 439 bytes
16cab053 — Christopher Vittal Make test scripts POSIX compliant 1 year, 6 months ago
                                                                                
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
#!/bin/sh
tool="tty"
. "$HARNESS"

should_print_tty() {
	if [ "$(uname)" != "Linux" ]
	then
		printf "SKIP(requires Linux) "
		return
	fi
	tty=$(tty)
	if [ "$tty" = "not a tty" ]
	then
		printf "SKIP(not a tty) "
		return
	fi
	[ "$(tty | cut -d/ -f2)" = "dev" ]
}

should_print_notty() {
	tty=$(tty </dev/null)
	[ "$tty" = "not a tty" ]
}

should_handle_ddash tty

runtests \
	should_handle_ddash \
	should_print_tty \
	should_print_notty