OILS / demo / path-cache.sh View on Github | oilshell.org

31 lines, 16 significant
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
10set -o nounset
11set -o pipefail
12set -o errexit
13
14sh-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
21main() {
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"$@"