OILS / test / gold / export.sh View on Github | oilshell.org

65 lines, 40 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./export.sh <function name>
5
6#set -o nounset
7set -o pipefail
8set -o errexit
9
10printenv() {
11 spec/bin/printenv.py "$@"
12}
13
14f1() {
15 local f1_str=f1_str
16 local f1_exported=f1_exported
17
18 export f1_exported
19
20 echo -n 'in f1: '
21 printenv f1_exported
22
23 f1_global=f1_global
24 export f1_global
25
26 # f1_exported gets CLEANED UP here.
27}
28
29f1
30
31echo $f1_str
32# This doesn't look in the environment? Oh I guess it gets cleaned up at the
33# end.
34
35echo -n 'global: '
36printenv f1_exported
37echo $f1_exported
38
39f1_global=AAA # mutate exported variable
40echo $f1_global
41printenv f1_global
42
43# oil:setandexport
44export E1=E1_VAL
45printenv E1
46unset E1
47echo "E1: $E1" # no longer set
48printenv E1 # no longer exported
49
50export E1=E1_VAL
51export -n E1
52echo "E1: $E1" # Still set! export and export -n aren't inverses.
53printenv E1
54
55echo ---
56
57myexport() {
58 # hm this is fully dynamic. Not statically parseable!
59 export "$@"
60}
61E3=E3_VAL
62myexport E2=E2_VAL E3
63echo "E2: $E2"
64echo "E3: $E3"
65printenv E2 E3