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

37 lines, 20 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./readlink-demo.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10two-file-symlinks() {
11 # NOTE: Two levels of symlinks requires readlink -f, not readlink.
12 ln -s -f $PWD/demo/readlink-demo-target.sh /tmp/demo.sh
13 ln -s -f /tmp/demo.sh /tmp/demo-level2.sh
14
15 # Call readlink-demo-target.sh through TWO file symlinks
16 /tmp/demo-level2.sh
17}
18
19dir-symlink() {
20 ln -s -f --no-target-directory $PWD/demo/ /tmp/oil-demo
21
22 # Calling readlink-demo-target.sh when a PATH component is a symlink to a
23 # directory
24 /tmp/oil-demo/readlink-demo-target.sh
25}
26
27all() {
28 echo 'Two files:'
29 two-file-symlinks
30 echo
31
32 echo 'Dirs:'
33 dir-symlink
34 echo
35}
36
37"$@"