Skip to content

3 Finger Claw⚓︎


#!/usr/bin/env sh

# POSIX compatible functions to enable reliable scripts

# credit to original authors
# 3 finger claw - https://youtu.be/S_aTzXVRRlM
# William Baxter (safe/try pattern originator)
# Matthew Story (loads of use)
# [email protected] (try refinements, config conventions)
# Allan Jude (try - the actual name)

# place the following at the top of your script
shout() { echo "$0: $*" >&2; }
die() { shout "$*"; exit 111; }
try() { "[email protected]" || die "cannot $*"; }

# example usage with optional logger

logger "Starting 3 finger protected commands"
try cd /some/place
try tar xfv /missing/file.tar
logger "Finished 3 finger protected commands"

true