Skip to content

Instantly share code, notes, and snippets.

@bertvv
Last active November 3, 2025 10:52
Show Gist options
  • Select an option

  • Save bertvv/7727082 to your computer and use it in GitHub Desktop.

Select an option

Save bertvv/7727082 to your computer and use it in GitHub Desktop.
Simple Bash script template
#!/bin/bash
#
# Script name -- purpose
#
# Author:
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide some errors in pipes
#
# Variables
#
#
# Main function
#
main() {
if [ "$#" -ne "1" ]; then
echo "Expected 1 argument, got $#" >&2
usage
exit 2
fi
}
#
# Helper functions
#
# Print usage info
usage() {
cat << _EOF_
Usage: ${0}
_EOF_
}
# Call the main function
main "${@}"
@AhmadAlhajKarim
Copy link

Waarom moeten wij in line 30 de stdout dwingen naar stderr ? Heeft het echt nut?

@bertvv
Copy link
Author

bertvv commented Sep 16, 2024

Het commando op lijn 30 drukt een foutboodschap af, dus het is nuttig dit naar stderr af te drukken om een onderscheid te maken met de "normale" output van het script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment