1 | #!/bin/sh
|
2 | #
|
3 | # Bug copied from _build/oils.sh
|
4 |
|
5 | # Usage:
|
6 | # demo/dash-bugs.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | #set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | compile_one() {
|
13 | echo compile_one "$@"
|
14 | sleep 1
|
15 | }
|
16 |
|
17 | _compile_one() {
|
18 | #local src=$4
|
19 |
|
20 | #echo "CXX $src"
|
21 |
|
22 | echo _do_fork=${_do_fork:-}
|
23 |
|
24 | # Delegate to function in build/ninja-rules-cpp.sh
|
25 | if test "${_do_fork:-}" = 1; then
|
26 | echo FORKING
|
27 | compile_one "$@" & # we will wait later
|
28 | else
|
29 | compile_one "$@"
|
30 | fi
|
31 | }
|
32 |
|
33 | demo() {
|
34 | # Early versions of dash run this incorrectly!
|
35 |
|
36 | _do_fork=1 _compile_one A
|
37 |
|
38 | # Workaround for bug in old version of dash!
|
39 | # The variable should not persist, but it does!
|
40 | _do_fork=
|
41 |
|
42 | _compile_one B
|
43 | _compile_one C
|
44 |
|
45 | wait
|
46 | }
|
47 |
|
48 |
|
49 | "$@"
|