File: cmdline

package info (click to toggle)
sasa 0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 168 kB
  • sloc: ansic: 400; sh: 191; python: 36; makefile: 34
file content (65 lines) | stat: -rwxr-xr-x 1,707 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -e

: "${SOCKET_ACTIVATE:=socket-activate}"

stdout='tests/stdout'
stderr='tests/stderr'

res=0
"$SOCKET_ACTIVATE" --help >"$stdout" 2>"$stderr" || res="$?"
if [ -s "$stderr" ]; then
	echo "$SOCKET_ACTIVATE --help exited with code $res and output some errors:" >&2
	cat -- "$stderr" >&2
	exit 1
fi
if [ "$res" != 0 ]; then
	echo "$SOCKET_ACTIVATE --help exited with code $res" >&2
	exit 1
fi
if ! fgrep -qie usage -- "$stdout"; then
	echo "$SOCKET_ACTIVATE --help did not say anything about usage:" >&2
	cat -- "$stdout" >&2
	exit 1
fi

res=0
"$SOCKET_ACTIVATE" --version >"$stdout" 2>"$stderr" || res="$?"
if [ -s "$stderr" ]; then
	echo "$SOCKET_ACTIVATE --version exited with code $res and output some errors:" >&2
	cat -- "$stderr" >&2
	exit 1
fi
if [ "$res" != 0 ]; then
	echo "$SOCKET_ACTIVATE --version exited with code $res" >&2
	exit 1
fi
if ! egrep -qe 'socket-activate[[:space:]]+[0-9]' -- "$stdout"; then
	echo "$SOCKET_ACTIVATE --version did not introduce itself:" >&2
	cat -- "$stdout" >&2
	exit 1
fi

if [ -n "$(command -v feature-check)" ]; then
	feature-check -- "$SOCKET_ACTIVATE" socket-activate
else
	echo 'No feature-check, checking the old-fashioned way'

	res=0
	"$SOCKET_ACTIVATE" --features >"$stdout" 2>"$stderr" || res="$?"
	if [ -s "$stderr" ]; then
		echo "$SOCKET_ACTIVATE --features exited with code $res and output some errors:" >&2
		cat -- "$stderr" >&2
		exit 1
	fi
	if [ "$res" != 0 ]; then
		echo "$SOCKET_ACTIVATE --features exited with code $res" >&2
		exit 1
	fi
	if ! egrep -qe 'Features:.*[[:space:]]socket-activate=[0-9]' -- "$stdout"; then
		echo "$SOCKET_ACTIVATE --features did not introduce itself:" >&2
		cat -- "$stdout" >&2
		exit 1
	fi
fi