GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - romw314/bashfox: A small bash script builder/framework.

BranchesTags
Open more actions menu

Latest commit

 

History

65 Commits
65 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.semaphore
.semaphore
 
 
website
website
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bashfox.bash
bashfox.bash
 
 
install.bash
install.bash
 
 
uninstall.bash
uninstall.bash
 
 

Repository files navigation

BashFOX

A small bash script builder/framework.

Installation

Using an install script (Recommended)

By this way, you will need Bash, cURL, Perl, and coreutils installed. You will not need Git.

curl -L https://github.com/romw314/bashfox/raw/master/install.bash | bash
. ~/.bashrc

Please note that the install script modifies your .bashrc, which means that you need to use . ~/.bashrc in order to use BashFOX.

Manually

This way you will need Git and coreutils installed.

git clone https://github.com/romw314/bashfox
cd bashfox
chmod 755 bashfox.bash
mkdir -p ~/.local/bin
cp bashfox.bash ~/.local/bin/bashfox

Please ensure that ~/.local/bin is in your path after manual installation.

Uninstallation

You will need Bash, cURL, Perl, and coreutils installed. You will not need Git. If you installed BashFOX with the install script uninstall it with:

curl -L https://github.com/romw314/bashfox/raw/master/uninstall.bash | bash

Elsewhere, simply remove the symlink from ~/.local/bin:

rm ~/.local/bin/bashfox

Usage

Write your code to .bash files. See the examples for more information.

Write your entry code to main.bash.

Write your configuration to bashfox.conf (see the examples).

Compile it using bashfox.

Example

src/main.bash

# It's important not to place comments on the same line
# as `import`, `debug`, `warn`, or any other BashFOX command.
# `import` imports a script without building it
# (useful for importing libraries that are already built, see lib/lib.bash)
import ../lib/lib.bash
debug  "This shows only if you use DEBUG=1"
notice "EXAMPLE notice"
info   "hello"
warn   "There is no useful code in this script"
if [ "$1" == "hello" ]; then
  fatal "The first argument shouldn't be 'hello'"
fi
# Include is the same as `import`, but builds the script.
# Script imported by `include` can contain BashFOX commands.
include extras/help.bash
error "Something went wrong"

src/extras/help.bash

# lib.bash is imported only once because of the _LIB_BASH variable.
import ../../lib/lib.bash

if [ "$1" == "help" ]; then
  info "USAGE:"
  info "$0 $(lib.wrap_in_brackets help) ..."
  info "Don't pass 'hello' to the first argument!"
  exit 0
fi

lib/lib.bash

# Here we can't use BashFOX commands.

if [ -z "$_LIB_BASH" ]; then
  # We don't export this, because we want to re-import the library
  # in scripts executed (not imported) from main.bash.
  _LIB_BASH=1

  # This library is named 'lib'.
  # We don't have namespaces in bash,
  # but we can declare functions with a dot.
  lib.wrap_in_brackets() {
    # Declare uses local variables unless -g is passed, so it is right here.
    declare result=''
    while (( "$#" )); do
      result="$result [$1]"
      shift
    done
    echo "${result:1}"
  }
fi

bashfox.conf

OUTPUT=outscript.bash # The output bash script
SOURCE=src            # The directory where main.bash is

Compilation and running

$ bashfox
BashFOX by romw314
SUCCESS
$ ./outscript.bash
[NOTICE] EXAMPLE notice
[ INFO ] hello
[ WARN ] There is no useful code in this script
[  ERR ] Something went wrong
$ ./outscript.bash hello
[NOTICE] EXAMPLE notice
[ INFO ] hello
[ WARN ] There is no useful code in this script
[ FATAL] The first argument shouldn't be 'hello'
$ ./outscript.bash help
[NOTICE] EXAMPLE notice
[ INFO ] hello
[ WARN ] There is no useful code in this script
[ INFO ] USAGE:
[ INFO ] ./outscript.bash [help] ...
[ INFO ] Don't pass 'hello' to the first argument!

About

A small bash script builder/framework.

h10.ngw1.rf.gd/bashfox/

Topics

bashbash-libbash-librarybash-shellbuildercompilerframeworklinuxlinux-bashlinux-shellshellubuntuubuntu-linuxubuntu-ltsubuntu2204ubuntu2204lts

Resources

Readme
Unlicense

Contributing

Contributing
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.