Skip to content

Instantly share code, notes, and snippets.

@tacone
Last active January 23, 2024 15:22
Show Gist options
  • Save tacone/c7487ff272d1ab7820a166395efab7e0 to your computer and use it in GitHub Desktop.
Save tacone/c7487ff272d1ab7820a166395efab7e0 to your computer and use it in GitHub Desktop.
bash logging function
#!/bin/bash
ignore () { true }
warning () { echo "$@" }
error () { ERR=$?; echo "$@"; return $ERR }
# --- Usage
#
# set -e;
#
# ls myfile || ignore
#
# ls myfile || warning "file not found"
#
# ls myfile || error "file not found, aborting!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment