bash-scripting
Instructions in case if any bash (or any shell in general) script is needed.
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
When determining where script is if needed, always use
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if refering something from ROOT directory is needed then define ROOT based on DIR in relative manner from current script like:
ROOT="${DIR}/.."
or
ROOT="${DIR}/../.."
... depends how many directories up we have to go
Don't use shebang at the top of the file.
Call script like this:
/bin/bash ${DIR}/script.sh
When using variables always surround them with ${}.
never $DIR, always ${DIR}
error handling
Before exit with non zero exit code from script in case of error always print the message what's happened like so:
echo "${0} error: [and then message here]"
this way we will spit out information about origin of the error - when it comes to which script is it.
Add to the message any relevent parameters values like so
"name of env var MY_ENV_VAR=>${MY_ENV_VAR}<"
(surround with ><, this way I will see any whitespaces at the beginning or end of the value)
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-01-20
- Mise à jour de l’index
- 2026-01-26
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!