bash-scripting
Instructions in case if any bash (or any shell in general) script is needed.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
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)
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!