-
Notifications
You must be signed in to change notification settings - Fork 149
/
env.sh
32 lines (20 loc) · 640 Bytes
/
env.sh
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
# POSIX 7
# Show all environment variables and their values:
#env
# Sample output:
#A=b c
#B=de
# Change environment for a single command:
a='b'
[ "$(env a='c' bash -c 'echo "$a"')" = 'c' ] || exit 1
[ "$a" = 'b' ] || exit 1
# In bash it is also possible to omit `env` TODO POSIX?:
a='b'
[ "$(a='c' bash -c 'echo "$a"')" = 'c' ] || exit 1
[ "$a" = 'b' ] || exit 1
## i
# Run command in a clean environment without inheriting exports
# except those explicitly given.
export a='b'
[ "$(env -i c='d' env)" = 'c=d' ] || exit 1
# There are some special variables however that do get exported anyways: