aboutsummaryrefslogtreecommitdiff
path: root/testsuite/env.tests
blob: 456808728ae295ec11d46f217d015712770a1d9d (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
67
#!/bin/sh
# Copyright 2022 by Ron Yorston
# Licensed under GPLv2, see file LICENSE in this source tree.

. ./testing.sh

# testing "test name" "commands" "expected result" "file input" "stdin"

# Not so much a test of 'env' as of whether environment variables
# (or the lack thereof) are correctly passed to child processes.
testing "environment variables 1a" \
	"V=set env sh -c 'env | grep ^V='" \
	"V=set
" "" ""

testing "environment variables 1b" \
	"V= env sh -c 'env | grep ^V='" \
	"V=
" "" ""

testing "environment variables 1c" \
	"env sh -c 'env | grep ^V='" \
	"" "" ""

testing "environment variables 2a" \
	"V=set sh -c 'env | grep ^V='" \
	"V=set
" "" ""

testing "environment variables 2b" \
	"V= sh -c 'env | grep ^V='" \
	"V=
" "" ""

testing "environment variables 2c" \
	"sh -c 'env | grep ^V='" \
	"" "" ""

testing "environment variables 3a" \
	"V=set env sh -c 'echo \${V-unset}'" \
	"set
" "" ""

testing "environment variables 3b" \
	"V= env sh -c 'echo \${V-unset}'" \
	"
" "" ""

testing "environment variables 3c" \
	"env sh -c 'echo \${V-unset}'" \
	"unset
" "" ""

testing "environment variables 4a" \
	"V=set sh -c 'echo \${V-unset}'" \
	"set
" "" ""

testing "environment variables 4b" \
	"V= sh -c 'echo \${V-unset}'" \
	"
" "" ""

testing "environment variables 4c" \
	"sh -c 'echo \${V-unset}'" \
	"unset
" "" ""