1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Test how many calls to execve() there are.
|
4 | # This is also a good demo of extraneous stat() calls at startup! bash has a
|
5 | # bunch.
|
6 | #
|
7 | # Usage:
|
8 | # ./path-cache.sh <function name>
|
9 |
|
10 | set -o nounset
|
11 | set -o pipefail
|
12 | set -o errexit
|
13 |
|
14 | sh-demo() {
|
15 | local sh=$1
|
16 | local syscalls='execve,stat,lstat,access'
|
17 | #local syscalls='execve'
|
18 | strace -ff -e $syscalls -- $sh -c 'whoami; whoami'
|
19 | }
|
20 |
|
21 | main() {
|
22 | for sh in dash bash bin/osh; do
|
23 | echo $'\t---'
|
24 | echo $'\t'$sh
|
25 | echo $'\t---'
|
26 |
|
27 | sh-demo $sh
|
28 | done
|
29 | }
|
30 |
|
31 | "$@"
|