Skip to content

potherca-bash/includes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Potherca BASH -- Includes

Non-code building blocks for BASH scripts.

project-stage-badge license-badge

Introduction

This repository contains files that hold comments, declarations or other common non-code lines often used in (my) BASH scripts. Instead of copy/pasting these lines, this repository offers a way of installing them as a dependecy (using BPKG). They can then be included from BASH scripts using source.

They are meant to serve as building blocks for BASH scripts.

Installation

This repository can be installed in several ways:

  • Using bpkg
  • Cloning the repository
  • Downloading the archive for a given release

Using bpkg

Available as a bpkg package:

bpkg install 'potherca-bash/includes'

This will install all available files in the deps/ directory of the project that bpkg has been run in.

Cloning the repository

git clone '[email protected]:potherca-bash/includes.git'

Downloading the archive

The latest release will always be tagged latests. To download the latest archive:

curl -L -o 'includes.tar.gz' 'https://github.com/potherca-bash/includes/archive/latest.tar.gz'
tar -xvzf 'includes.tar.gz'

Usage

Simply include a file using source:

#!/usr/bin/env bash


source './deps/includes/src/declare/declare.bash-options.inc'
source './deps/includes/src/comment/license/comment.license-gpl3.inc'
source './deps/includes/src/declare/declare.color.inc'
source './deps/includes/src/declare/declare.exit-codes.inc'

# ...
# Script logic goes here
# ...

This works best when used during development, for production it is advisable to compile a version from the script that replaces the source entries with the content of the included file(s).

Development

To make code changes, fork this repository and install the needed dependecies:

cd './includes'
bpkg getdeps

Pull/Merge-request are welcomed.

Motivation

When creating BASH script, I found myself copy/pasting certain lines of comment or code over and over. It seemed more sensible to separate those lines into separate files and just include the files from other scripts. This repository is part of that effort. Others can be found at https://github.com/potherca-bash/.

Colophon