This is a slowly growing collection of hopefully useful and reusable shell functions and patterns. https://code.jan.io/jan/jans_shell_utils
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
314B

  1. # Copyright (c) 2022 Jan Lehnardt <jan@apache.org>, MIT licensed
  2. debug () {
  3. if [ -n "$DEBUG" ]; then
  4. echo "$1"
  5. fi
  6. }
  7. debug_inline () {
  8. if [ -n "$DEBUG" ]; then
  9. printf "$1"
  10. fi
  11. }
  12. error_and_exit () {
  13. echo $1 || "error"
  14. exit 1
  15. }
  16. assert_arg () {
  17. arg=$1
  18. if [ -z "$arg" ]; then
  19. return 1
  20. fi
  21. return 0
  22. }