ElectricRCAircraftGuy / ElectricRCAircraftGuy.github.io

My github pages website at gabrielstaples.com
https://gabrielstaples.com/
5 stars 1 forks source link

https://gabrielstaples.com/bash-libraries/ #49

Closed utterances-bot closed 1 year ago

utterances-bot commented 1 year ago

How do you write, import, use, and test libraries in Bash? | GabrielStaples.com home

Here’s a really beautiful, almost Python-like style I’ve come with over the years for writing and using Bash libraries. Bash is a beautiful “glue”-type language which allows you to easily tie together executables from many languages. Considering how long Bash has been around, I’m not sure why the below style isn’t more popular, but perhaps it hasn’t been thought of or used this way before. So, here goes. I think you’ll find it really useful.

https://gabrielstaples.com/bash-libraries/

ElectricRCAircraftGuy commented 1 year ago

Example usage of my library now, right inside any terminal:

# 1. Source it using a relative path to it
$ . ../eRCaGuy_hello_world/bash/libraries/floating_point_math.sh

# 2. Do (1 + 2 + 3)*2.1, which is 12.6
$ echo "$(mul $(add 1 2 3) 2.1)"
12.6