Giter VIP home page Giter VIP logo

shellbase's Introduction

Shellbase

             ,,                 ,,    ,,  ,,
           `7MM               `7MM  `7MM *MM
             MM                 MM    MM  MM
    ,pP"Ybd  MMpMMMb.  .gP"Ya   MM    MM  MM,dMMb.   ,6"Yb.  ,pP"Ybd  .gP"Ya
    8I   `"  MM    MM ,M'   Yb  MM    MM  MM    `Mb 8)   MM  8I   `" ,M'   Yb
    `YMMMa.  MM    MM 8M""""""  MM    MM  MM     M8  ,pm9MM  `YMMMa. 8M""""""
    L.   I8  MM    MM YM.    ,  MM    MM  MM.   ,M9 8M   MM  L.   I8 YM.    ,
    M9mmmP'.JMML  JMML.`Mbmmd'.JMML..JMML.P^YbmdP'  `Moo9^Yo.M9mmmP'  `Mbmmd'

test hits of code release) license

About

The shellbase framework serves as a foundation for Unix shell scripts. This framework is mostly POSIX-compliant, Portable Operating System Interface for uniX, ensuring compatibility across Unix-like systems. It offers a range of essential services, including public functions such as logger and multiple validations, signal handling, garbage collection, and support for multiple instances.

The shellbase defines global variables and functions. All functions without base_ prefix are public and could be used by clients. The public functions are, in alphabetical order: aud_only, beroot, beuser, bomb, cheat, cmd_exists, chrono_get, chrono_sta, chrono_sto, cya, die, echo, file_exists, grbt, handle_pipefails, heic2jpg, inside, isempty, isfunc, isnumber, isreadable, issolid, iswritable, log, loge, logw, map_del, map_get, map_put, pdf2jpg, pdf2png, prettytable, prettyuptime, realdir, realpath, semver, should_continue, timestamp, tolog, tologe, tolower, totsout, tsout, url_exists, user_exists, validate_cmd, validate_var, var_exists, ver_ge, vid2aud, yes_to_continue, ytda.

Global variables have BASE_ prefix and clients could use them. Clients should place temporary files under $BASE_WIP. All functions started with base_ prefix are internal and should not be used by clients. The names are arranged in alphabetical order.

See dotfiles, gento, and toolbox as examples of projects that utilize this framework.

Install

The artifact is a single non-executable POSIX-compliant shell script file base.sh. Install the file from the repository:

git clone [email protected]:rdavid/shellbase.git &&
  ./shellbase/app/install

Install the file from the released version. Some operating systems demands administrative rights to install to /usr/local/bin, use sudo or doas before tar:

REL=0.9.20240707
SRC=https://github.com/rdavid/shellbase/archive/refs/tags/v$REL.tar.gz
curl --location --silent $SRC |
  tar \
    --directory /usr/local/bin \
    --extract \
    --gzip \
    --strip-components=2 \
    shellbase-$REL/lib/base.sh

Verify /usr/local/bin is in your PATH. Then your script can use shellbase:

#!/bin/sh
# shellcheck disable=SC1091 # File not following.
. base.sh
log I\'m using the shellbase.

You can try shellbase without installation:

#!/bin/sh
REL=0.9.20240707
SRC=https://github.com/rdavid/shellbase/archive/refs/tags/v$REL.tar.gz
eval "$(
  curl --location --silent $SRC |
    tar \
      --extract \
      --gzip \
      --to-stdout \
      shellbase-$REL/lib/base.sh
)"
log I\'m using the shellbase.

prettytable example:

. base.sh
{
  printf 'ID\tNAME\tTITLE\n'
  printf '123456789\tJohn Foo\tDirector\n'
  printf '12\tMike Bar\tEngineer\n'
} | prettytable

Output:

+-----------+----------+----------+
|ID         |NAME      |TITLE     |
+-----------+----------+----------+
|123456789  |John Foo  |Director  |
|12         |Mike Bar  |Engineer  |
+-----------+----------+----------+

Test

The project uses Daniel J. Bernstein’s build system redo. You can install Sergey Matveev’s goredo implementation. redo lint applies the following linters to the source files: checkmake, hadolint, shellcheck, shfmt, typos, vale, yamllint. redo test runs unit tests in installed shells. redo test-container runs the tests across various shells in containers. It uses David Rabkin's goredoer to build goredo.

License

shellbase is copyright David Rabkin and available under a Zero-Clause BSD license.

shellbase's People

Contributors

dependabot[bot] avatar rdavid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.