Goal
No more spending time searching the special ways of bash for basic operations like "how to replace a string in bash", then compare, choose, and test among many potential solutions.
Bash-base does this for you, you can just call the function here which is well tested and stable, and only focus you on the high level logic. Writing your script with less time, but more readability.
Quick start
Creat a sample script example_docker.sh
with the following content:
#!/usr/bin/env bash
source <(docker run renaultdigital/bash-base)
SHORT_DESC='an example shell script to show how to use bash-base '
args_parse $# "$@" firstName age sex country
args_valid_or_read firstName '^[A-Za-z ]{2,}$' "Your first name (only letters)"
args_valid_or_read age '^[0-9]{1,2}$' "Your age (maxim 2 digits))"
args_valid_or_select_pipe sex 'Mr.|Mrs' "Your sex"
response=$(curl -sS 'https://restcountries.eu/rest/v2/regionalbloc/eu' --compressed)
string_pick_to_array '{"name":"' '","topLevelDomain' countryNames "$response"
args_valid_or_select country countryNames "Which country"
print_success "Hello $sex $(string_upper_first "$firstName"), you are in $country, and your age is $age, nice to meet you."
Assign the execute
right to it:
chmod +x example_docker.sh
Print the generated help usage with the option -h
:
Run it:
Available on github, npm and dockerhub, see other ways of usage.
Example
See example folder
Reference
See reference
Specification
See spec folder
Latest Update
See CHANGELOG.md
Contributing
See How to contribute
License
MIT.