Bash helpers

Last Commit 7acfc6e (August 30, 2025 12:00 am)
Repository https://github.com/magicoli/bash-helpers
License Copyright (c) 2015, Olivier van Helden olivier@van-helden.net

Copyright 2015 Olivier van Helden olivier@van-helden.net. Released under GNU Affero GPL v3.0 license, unless otherwise stated. http://www.gnu.org/licenses/agpl-3.0.html

A couple of useful tools for bash scripting.

helpers

Put this line at the beginning of your script (do not run the file directly, source it):

. /path/to/helpers

and use these functions inside the script

end [errornumber] [message]
log [errornumber] [message]
readvar [var]
yesno [-y] ["message"]
ucfirst [string]

ini_parser

A tool to read .ini config in bash scripts

let’s say you have a .ini file with this content

[Default]
    name = "Albert"
[Smart]
    name = "Einstein"

Put this line at the beginning of your script (do not run the file directly, source it):

. /path/to/ini_parser

And, where you need it

ini.parse /path/to/config/file.ini
ini.section.Default
echo $name

Output: Albert

Then, later… (no need to repeat ini.parse /path/to/config/file.ini)

ini.section.Smart
echo $name

Output: Einstein

Voilà ! (en français dans le texte)

More details inside ini_parser

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)