Compare commits
102 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2e878ec30f | ||
|
726ce78de7 | ||
|
51e7644bb1 | ||
|
985b0046c4 | ||
|
38f269c660 | ||
|
f6b61410c0 | ||
|
42e50f66c8 | ||
|
c5012d0190 | ||
|
14421bd791 | ||
|
7af1f75c5e | ||
|
320609fceb | ||
|
9e70d61133 | ||
|
354c304b19 | ||
|
a6a2d961ae | ||
|
7f9a31f8d8 | ||
|
758fa92f05 | ||
|
555beb1add | ||
|
2d145e24e9 | ||
|
b2140d5ec6 | ||
|
7a022bccf3 | ||
|
55cd329ebd | ||
|
879422d09f | ||
|
1fb7cc4337 | ||
|
f2ccef5b36 | ||
|
2e68b71743 | ||
|
28deb39d86 | ||
|
33a3fd706b | ||
|
ddc6440177 | ||
|
c4585291f3 | ||
|
9a27140e7e | ||
|
cb06f0aa70 | ||
|
e45247d4aa | ||
|
a50ad7007e | ||
|
41172fcc8f | ||
|
9f0c37e2ac | ||
|
0a6e3925dc | ||
|
7d3927b025 | ||
|
49eed4f283 | ||
|
3d47083fcf | ||
|
e516a60169 | ||
|
d1c26b9ac1 | ||
|
85efe41ad9 | ||
|
80ab935cf6 | ||
|
86f20e34b7 | ||
|
d113e87c96 | ||
|
9f06b1a8c6 | ||
|
8a14c0e3d5 | ||
|
c086796573 | ||
|
05cdcdaa12 | ||
|
8ceed901d5 | ||
|
76fbd2104b | ||
|
9cc3bf124c | ||
|
986fec8090 | ||
|
ea15c44c7e | ||
|
febd9e354b | ||
|
13d74bb4f1 | ||
|
ab3857e3bd | ||
|
e5da0aa249 | ||
|
bbb8afea4d | ||
|
e078dd2b91 | ||
|
9fd3f1df64 | ||
|
1005ceeec8 | ||
|
56eab89caa | ||
|
186d9ff6a0 | ||
|
23ce0e6b85 | ||
|
6392674f70 | ||
|
222a95793b | ||
|
269627deec | ||
|
1238b67abe | ||
|
5cc417485a | ||
|
971a83ea3a | ||
|
14dc823cca | ||
|
599faf3830 | ||
|
0d096350b0 | ||
|
24e7ceaaf7 | ||
|
f1ad8a5655 | ||
|
c0f58127bb | ||
|
6689117e5d | ||
|
a28d594d5f | ||
|
bccefb0061 | ||
|
9194295c64 | ||
|
8146667ea1 | ||
|
2019caa899 | ||
|
357ea3778a | ||
|
f377dfb16e | ||
|
f77b400dc9 | ||
|
03662dd404 | ||
|
b8a4aba3c2 | ||
|
685442bbcc | ||
|
16b543114b | ||
|
7791e3ca0f | ||
|
1152cc3cf7 | ||
|
b4048f3f12 | ||
|
11cd18e179 | ||
|
05f35415a6 | ||
|
ec9087f0d2 | ||
|
5a9a68be2b | ||
|
97f9676754 | ||
|
83c77f8df3 | ||
|
04cf154b3e | ||
|
4085bc461e | ||
|
8e548e766e |
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,7 +1,7 @@
|
||||
Thanks for contributing to b3bp! As part of your PR, have you:
|
||||
|
||||
- [ ] Added an item in [CHANGELOG.md](https://github.com/kvz/bash3boilerplate/blob/master/CHANGELOG.md) with attribution?
|
||||
- [ ] Added your name to the [README.md](https://github.com/kvz/bash3boilerplate/blob/master/README.md#authors)
|
||||
- [ ] Added an item in [CHANGELOG.md](https://github.com/kvz/bash3boilerplate/blob/HEAD/CHANGELOG.md) with attribution?
|
||||
- [ ] Added your name to the [README.md](https://github.com/kvz/bash3boilerplate/blob/HEAD/README.md#authors)
|
||||
- [ ] Linted your code? (`make test` should do the trick)
|
||||
|
||||
If so, great! Feel free to replace this message with a description of your work and hit submit!
|
||||
|
5
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
groups:
|
||||
production-dependencies:
|
||||
dependency-type: 'production'
|
||||
development-dependencies:
|
||||
dependency-type: 'development'
|
30
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: b3bp CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
- name: Install
|
||||
run: |
|
||||
corepack yarn
|
||||
- name: Lint
|
||||
env:
|
||||
SHELLCHECK_SEVERITY: warning
|
||||
run: |
|
||||
corepack yarn lint
|
||||
- name: Test
|
||||
run: |
|
||||
corepack yarn test
|
26
.gitignore
vendored
@ -1,23 +1,5 @@
|
||||
npm-debug.log
|
||||
node_modules
|
||||
|
||||
website/index.md
|
||||
website/_site/
|
||||
website/_vendor/
|
||||
|
||||
website/changelog.md
|
||||
|
||||
website/faq.md
|
||||
|
||||
website/.jekyll-metadata
|
||||
|
||||
env.sh
|
||||
|
||||
website/main.sh
|
||||
website/assets/build
|
||||
website/.lanyon
|
||||
website/.lanyon/vendor/bin
|
||||
website/.lanyon/bin
|
||||
.yarn
|
||||
assets/build
|
||||
.lanyon
|
||||
.lanyon/bin
|
||||
env.sh
|
||||
node_modules
|
||||
npm-debug.log
|
||||
|
3
.shellcheckrc
Normal file
@ -0,0 +1,3 @@
|
||||
external-sources=true
|
||||
shell=bash
|
||||
color=always
|
47
.travis.yml
@ -1,47 +0,0 @@
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js: 6
|
||||
- os: osx
|
||||
language: node_js
|
||||
node_js: 6
|
||||
env:
|
||||
global:
|
||||
- SCROLEX_MODE=passthru
|
||||
- secure: BeM6mpPEATdeFcAr/222QBZ9vRkZtU2WOi9QQy3mxsuDbWfM8RxYESIEJLipyhW9kXGoe6HGMqm4Kz9B/c4jrzeSXPpKnW7mIfnyqN+hhq1ctW9qPSqodu+fYNhdDxXh5wylml7hnIJzU70vFGrFknZRE2FYk5XvyHg2ImIKDJw=
|
||||
- secure: RJ5UpdXms9QkraylZ11OBfmcRrmKnb254Yj0yCDAvZmg+n+3jSTwMgGvPY8Ih8X/R1JeW3VTtFDkJXXPnjjfpNg1M91u4CAEUOMPciCudYcoF6GKb8psnOzneTTX5M7zuJSzknGdpv/foldxiPYxiY5Hn5bfjmikhAEl+QX/R0Y=
|
||||
- secure: BXf2buPt/DA09M5ZUdp/LpOWtUuz1mfCBopLyxvHv3Sl3ln+Az57wWsM2+Re+77lUOgihR2f6lXYfNUmQuSUo157rZPunQCqM/DJhK69KhREEB6SJDaJF3FVlnGla+Cwwb1IQUtMopqX9pBYD7w/zyWQFJCi20O57JEVIdfZZS8=
|
||||
- secure: AaDI3OLTcwau2tu9jTtR0eHpylSUudYua9aKH3C540Lm2scQhQcT4IbMa6KXgrY+1UchapS9gUuClH8QwgJo61tJjtOqvmCgZ2EkmZg68pzw/25zwv7LSzYASbZvKahulV/giZdxFLGOpPhNhKbG70/owYXjKFENi5LoZKc8Y+c=
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- debian-sid
|
||||
install:
|
||||
- npm install
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then npm run install:lanyon; fi
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install --allow-unauthenticated -y cabal-install; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cabal update; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cabal install shellcheck; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gsed || brew install gnu-sed; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which gtimeout || brew install coreutils; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then which bundle || gem install bundler; fi
|
||||
- bash --version
|
||||
- awk --version
|
||||
before_cache:
|
||||
- rm -f ./node_modules/.bin/which
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- .lanyon
|
||||
script: test/acceptance.sh
|
||||
deploy:
|
||||
skip_cleanup: true
|
||||
provider: script
|
||||
script: ./node_modules/lanyon/scripts/ci-deploy.sh
|
||||
on:
|
||||
branch: master
|
||||
condition: $TRAVIS_OS_NAME = linux
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
"path": ".."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
1
.yarnrc.yml
Normal file
@ -0,0 +1 @@
|
||||
nodeLinker: node-modules
|
61
CHANGELOG.md
@ -8,18 +8,42 @@ Unplanned.
|
||||
|
||||
- [ ] Better style guide checking (#84)
|
||||
|
||||
## master
|
||||
## main
|
||||
|
||||
Released: TBA.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.4.0...master).
|
||||
Released: TBA.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/2.7.2...main).
|
||||
|
||||
- [ ] Upgrade to `lanyon@0.0.55`
|
||||
- [ ]
|
||||
|
||||
## v2.4.0
|
||||
## 2.7.2
|
||||
|
||||
Released: 2016-12-21.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.0).
|
||||
Released: 2023-08-29
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.4.1...2.7.2).
|
||||
|
||||
- [x] Upgrade and cleanup node dependencies
|
||||
- [x] Remove lanyon-based website in favor of simple redirect to github for bash3boilerplate.sh
|
||||
- [x] Make tests pass again
|
||||
- [x] Make linting and style checking separate actions
|
||||
- [x] Add feature to edit/update comments in ini file (#132, @rfuehrer)
|
||||
- [x] Upgrade to `lanyon@0.1.16`
|
||||
- [x] Capture correct error_code in err_report (#124, @eval)
|
||||
- [x] Enhanced ini file handling: create new file, create new sections, handle default section, read key from given section (@rfuehrer)
|
||||
|
||||
## v2.4.2
|
||||
|
||||
Released: 2019-11-07.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.4.1...v2.4.2).
|
||||
|
||||
- [x] Upgrade to `lanyon@0.1.16`
|
||||
- [x] Capture correct error_code in err_report (#124, @eval)
|
||||
- [x] Enhanced ini file handling: create new file, create new sections, handle default section, read key from given section (@rfuehrer)
|
||||
|
||||
## v2.4.1
|
||||
|
||||
Released: 2019-11-07.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.1).
|
||||
|
||||
- [x] Upgrade to `lanyon@0.1.7`
|
||||
- [x] Allow counting how many times an argument is used (@genesiscloud)
|
||||
- [x] Fix typos in megamount (thanks @gsaponaro)
|
||||
- [x] Enable color in screen or tmux (#92, @gmasse)
|
||||
@ -31,9 +55,16 @@ Released: 2016-12-21.
|
||||
- [x] Add support for repeatable arguments (@genesiscloud)
|
||||
- [x] Fix remaining warnings with shellcheck v0.7.0 (#107, @genesiscloud)
|
||||
|
||||
## v2.4.0
|
||||
|
||||
Released: 2016-12-21.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.0).
|
||||
|
||||
- [x] Upgrade to `lanyon@0.0.143`
|
||||
|
||||
## v2.3.0
|
||||
|
||||
Released: 2016-12-21.
|
||||
Released: 2016-12-21.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.2.0...v2.3.0).
|
||||
|
||||
- [x] Add magic variable `__i_am_main_script` to distinguish if b3bp is being sourced or called directly (#45, @zbeekman)
|
||||
@ -45,7 +76,7 @@ Released: 2016-12-21.
|
||||
|
||||
## v2.2.0
|
||||
|
||||
Released: 2016-12-21.
|
||||
Released: 2016-12-21.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.1.0...v2.2.0).
|
||||
|
||||
- [x] README and FAQ improvements (#66, @mstreuhofer)
|
||||
@ -67,7 +98,7 @@ Released: 2016-12-21.
|
||||
|
||||
## v2.1.0
|
||||
|
||||
Released: 2016-11-08.
|
||||
Released: 2016-11-08.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.0.0...v2.1.0).
|
||||
|
||||
- [x] Cleanup b3bp variables (adds prefixes across the board) (thanks @mstreuhofer)
|
||||
@ -94,7 +125,7 @@ Released: 2016-11-08.
|
||||
|
||||
## v2.0.0
|
||||
|
||||
Released: 2016-02-17.
|
||||
Released: 2016-02-17.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.2.1...v2.0.0).
|
||||
|
||||
- [x] Add tests for `templater` and follow Library export best practices
|
||||
@ -106,14 +137,14 @@ Released: 2016-02-17.
|
||||
|
||||
## v1.2.1
|
||||
|
||||
Released: 2016-02-17.
|
||||
Released: 2016-02-17.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.2.0...v1.2.1).
|
||||
|
||||
- [x] Add Travis CI automated testing for OSX (thanks @zbeekman)
|
||||
|
||||
## v1.2.0
|
||||
|
||||
Released: 2016-02-16.
|
||||
Released: 2016-02-16.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.1.0...v1.2.0).
|
||||
|
||||
- [x] Allow disabling colors via `NO_COLOR` environment variable
|
||||
@ -127,7 +158,7 @@ Released: 2016-02-16.
|
||||
|
||||
## v1.1.0
|
||||
|
||||
Released: 2015-06-29.
|
||||
Released: 2015-06-29.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.0.3...v1.1.0).
|
||||
|
||||
- [x] Add `ALLOW_REMAINDERS` configuration to templater
|
||||
@ -136,7 +167,7 @@ Released: 2015-06-29.
|
||||
|
||||
## v1.0.3
|
||||
|
||||
Released: 2014-11-02.
|
||||
Released: 2014-11-02.
|
||||
[Diff](https://github.com/kvz/bash3boilerplate/compare/5db569125319a89b9561b434db84e4d91faefb63...v1.0.3).
|
||||
|
||||
- [x] Add `ini_val`, `megamount`, `parse_url`
|
||||
|
63
FAQ.md
@ -1,23 +1,22 @@
|
||||
[This document is formatted with GitHub-Flavored Markdown. ]:#
|
||||
[For better viewing, including hyperlinks, read it online at ]:#
|
||||
[https://github.com/kvz/bash3boilerplate/blob/master/FAQ.md ]:#
|
||||
[This document is formatted with GitHub-Flavored Markdown. ]: #
|
||||
[For better viewing, including hyperlinks, read it online at ]: #
|
||||
[https://github.com/kvz/bash3boilerplate/blob/HEAD/FAQ.md ]: #
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is a CLI](#what-is-a-cli)?
|
||||
* [How do I incorporate BASH3 Boilerplate into my own project](#how-do-i-incorporate-bash3-boilerplate-into-my-own-project)?
|
||||
* [How do I add a command-line flag](#how-do-i-add-a-command-line-flag)?
|
||||
* [How do I access the value of a command-line argument](#how-do-i-access-the-value-of-a-command-line-argument)?
|
||||
* [What is a magic variable](#what-is-a-magic-variable)?
|
||||
* [How do I submit an issue report](#how-do-i-submit-an-issue-report)?
|
||||
* [How can I contribute to this project](#how-can-i-contribute-to-this-project)?
|
||||
* [Why are you typing BASH in all caps](#why-are-you-typing-bash-in-all-caps)?
|
||||
* [How can I locally develop and preview the b3bp website](#how-can-i-locally-develop-and-preview-the-b3bp-website)?
|
||||
* [You are saying you are portable, but why won't b3bp code run in dash / busybox / posh / ksh / mksh / zsh](#you-are-saying-you-are-portable-but-why-wont-b3bp-code-run-in-dash--busybox--posh--ksh--mksh--zsh)?
|
||||
* [How do I do Operating System detection](#how-do-i-do-operating-system-detection)?
|
||||
* [How do I access a potentially unset (environment) variable](#how-do-i-access-a-potentially-unset-environment-variable)?
|
||||
* [How can I detect or trap CTRL-C and other signals](#how-can-i-detect-or-trap-ctrl-c-and-other-signals)?
|
||||
* [How can I get the PID of my running script](how-can-i-get-the-pid-of-my-running-script)?
|
||||
- [What is a CLI](#what-is-a-cli)?
|
||||
- [How do I incorporate BASH3 Boilerplate into my own project](#how-do-i-incorporate-bash3-boilerplate-into-my-own-project)?
|
||||
- [How do I add a command-line flag](#how-do-i-add-a-command-line-flag)?
|
||||
- [How do I access the value of a command-line argument](#how-do-i-access-the-value-of-a-command-line-argument)?
|
||||
- [What is a magic variable](#what-is-a-magic-variable)?
|
||||
- [How do I submit an issue report](#how-do-i-submit-an-issue-report)?
|
||||
- [How can I contribute to this project](#how-can-i-contribute-to-this-project)?
|
||||
- [Why are you typing BASH in all caps](#why-are-you-typing-bash-in-all-caps)?
|
||||
- [You are saying you are portable, but why won't b3bp code run in dash / busybox / posh / ksh / mksh / zsh](#you-are-saying-you-are-portable-but-why-wont-b3bp-code-run-in-dash--busybox--posh--ksh--mksh--zsh)?
|
||||
- [How do I do Operating System detection](#how-do-i-do-operating-system-detection)?
|
||||
- [How do I access a potentially unset (environment) variable](#how-do-i-access-a-potentially-unset-environment-variable)?
|
||||
- [How can I detect or trap CTRL-C and other signals](#how-can-i-detect-or-trap-ctrl-c-and-other-signals)?
|
||||
- [How can I get the PID of my running script](how-can-i-get-the-pid-of-my-running-script)?
|
||||
|
||||
<!--more-->
|
||||
|
||||
@ -60,7 +59,7 @@ source main.sh
|
||||
|
||||
## How do I access the value of a command-line argument?
|
||||
|
||||
To find out the value of an argument, append the corresponding single-character flag to the text `$arg_`. For example, if the [read block]
|
||||
To find out the value of an argument, append the corresponding single-character flag to the text `$arg_`. For example, if the [read block]
|
||||
contains the line
|
||||
|
||||
```bash
|
||||
@ -83,7 +82,7 @@ Please visit our [Issues](https://github.com/kvz/bash3boilerplate/issues) page.
|
||||
|
||||
## How can I contribute to this project?
|
||||
|
||||
Please fork this repository. After that, create a branch containing your suggested changes and submit a pull request based on the master branch
|
||||
Please fork this repository. After that, create a branch containing your suggested changes and submit a pull request based on the main branch
|
||||
of <https://github.com/kvz/bash3boilerplate/>. We are always more than happy to accept your contributions!
|
||||
|
||||
## Why are you typing BASH in all caps?
|
||||
@ -94,30 +93,6 @@ This project's name, however, is "BASH3 Boilerplate". It is a reference to
|
||||
only for crafting webpages.
|
||||
Somewhat inconsistent – but true to Unix ancestry – the abbreviation for our project is "b3bp".
|
||||
|
||||
## How can I locally develop and preview the b3bp website?
|
||||
|
||||
You should have a working Node.js >=10, Ruby >=2 and [YARN](https://yarnpkg.com) install on your workstation. When that is the case, you can run:
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
npm run start
|
||||
```
|
||||
|
||||
This will install and start all required services and automatically open a webbrowser that reloads as soon as you make any changes to the source.
|
||||
|
||||
The source mainly consists of:
|
||||
|
||||
- `./README.md` (Front page)
|
||||
- `./FAQ.md` (FAQ page)
|
||||
- `./CHANGELOG.md` (changelog page)
|
||||
- `./website/_layouts/default.html` (the design in which all pages are rendered)
|
||||
- `./website/assets/app.js` (main JS file)
|
||||
- `./website/assets/style.css` (main CSS file)
|
||||
|
||||
The rest is dark magic from which you should probably steer clear. : )
|
||||
|
||||
Any changes should be proposed as PRs. Anything added to `master` is automatically deployed using a combination of Travis CI and GitHub Pages.
|
||||
|
||||
## You are saying you are portable, but why won't b3bp code run in dash / busybox / posh / ksh / mksh / zsh?
|
||||
|
||||
When we say _portable_, we mean across Bash versions. Bash is widespread and most systems
|
||||
@ -193,4 +168,4 @@ See http://mywiki.wooledge.org/SignalTrap for a list of signals, examples, and a
|
||||
|
||||
## How can I get the PID of my running script?
|
||||
|
||||
The PID of a running script is contained in the `${$}` variable. This is *not* the pid of any subshells. With Bash 4 you can get the PID of your subshell with `${BASHPID}`. For a comprehensive list of Bash built in variables see, e.g., http://www.tldp.org/LDP/abs/html/internalvariables.html
|
||||
The PID of a running script is contained in the `${$}` variable. This is _not_ the pid of any subshells. With Bash 4 you can get the PID of your subshell with `${BASHPID}`. For a comprehensive list of Bash built in variables see, e.g., http://www.tldp.org/LDP/abs/html/internalvariables.html
|
||||
|
25
Makefile
@ -3,6 +3,9 @@
|
||||
#
|
||||
# https://www.npmjs.com/package/fakefile
|
||||
#
|
||||
# Please do not edit this file directly, but propose changed upstream instead:
|
||||
# https://github.com/kvz/fakefile/blob/main/Makefile
|
||||
#
|
||||
# This Makefile offers convience shortcuts into any Node.js project that utilizes npm scripts.
|
||||
# It functions as a wrapper around the actual listed in `package.json`
|
||||
# So instead of typing:
|
||||
@ -25,10 +28,26 @@
|
||||
# OSX users will have to install bash-completion
|
||||
# (http://davidalger.com/development/bash-completion-on-os-x-with-brew/)
|
||||
|
||||
ifeq ($(shell test -e ./yarn.lock && echo -n yes),yes)
|
||||
RUNNER=yarn
|
||||
INSTALLER=yarn install
|
||||
else
|
||||
RUNNER=npm run
|
||||
INSTALLER=npm install
|
||||
endif
|
||||
|
||||
define npm_script_targets
|
||||
TARGETS := $(shell node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"));}')
|
||||
TARGETS := $(shell \
|
||||
node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"));}'
|
||||
| grep -v -E "^install$$"
|
||||
)
|
||||
$$(TARGETS):
|
||||
npm run $(subst -,:,$(MAKECMDGOALS))
|
||||
$(RUNNER) $(shell \
|
||||
node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"), k);}'
|
||||
| grep -E "^$(MAKECMDGOALS)\s"
|
||||
| head -n1
|
||||
| awk '{print $$2}'
|
||||
)
|
||||
|
||||
.PHONY: $$(TARGETS)
|
||||
endef
|
||||
@ -37,4 +56,4 @@ $(eval $(call npm_script_targets))
|
||||
|
||||
# These npm run scripts are available, without needing to be mentioned in `package.json`
|
||||
install:
|
||||
npm run install
|
||||
$(INSTALLER)
|
||||
|
69
README.md
@ -1,19 +1,17 @@
|
||||
[](https://travis-ci.org/kvz/bash3boilerplate)
|
||||
[This document is formatted with GitHub-Flavored Markdown. ]: #
|
||||
[For better viewing, including hyperlinks, read it online at ]: #
|
||||
[https://github.com/kvz/bash3boilerplate/blob/HEAD/README.md]: #
|
||||
|
||||
[This document is formatted with GitHub-Flavored Markdown. ]:#
|
||||
[For better viewing, including hyperlinks, read it online at ]:#
|
||||
[https://github.com/kvz/bash3boilerplate/blob/master/README.md]:#
|
||||
|
||||
* [Overview](#overview)
|
||||
* [Goals](#goals)
|
||||
* [Features](#features)
|
||||
* [Installation](#installation)
|
||||
* [Changelog](#changelog)
|
||||
* [Frequently Asked Questions](#frequently-asked-questions)
|
||||
* [Best Practices](#best-practices)
|
||||
* [Who uses b3bp](#who-uses-b3bp)
|
||||
* [Authors](#authors)
|
||||
* [License](#license)
|
||||
- [Overview](#overview)
|
||||
- [Goals](#goals)
|
||||
- [Features](#features)
|
||||
- [Installation](#installation)
|
||||
- [Changelog](#changelog)
|
||||
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||
- [Best Practices](#best-practices)
|
||||
- [Who uses b3bp](#who-uses-b3bp)
|
||||
- [Authors](#authors)
|
||||
- [License](#license)
|
||||
|
||||
## Overview
|
||||
|
||||
@ -21,10 +19,10 @@
|
||||
|
||||
When hacking up Bash scripts, there are often things such as logging or command-line argument parsing that:
|
||||
|
||||
- You need every time
|
||||
- Come with a number of pitfalls you want to avoid
|
||||
- Keep you from your actual work
|
||||
|
||||
- You need every time
|
||||
- Come with a number of pitfalls you want to avoid
|
||||
- Keep you from your actual work
|
||||
|
||||
Here's an attempt to bundle those things in a generalized way so that
|
||||
they are reusable as-is in most scripts.
|
||||
|
||||
@ -32,7 +30,7 @@ We call it "BASH3 Boilerplate" or b3bp for short.
|
||||
|
||||
## Goals
|
||||
|
||||
Delete-Key-**Friendly**. Instead of introducing packages, includes, compilers, etc., we propose using [`main.sh`](http://bash3boilerplate.sh/main.sh) as a base and removing the parts you don't need.
|
||||
Delete-Key-**Friendly**. Instead of introducing packages, includes, compilers, etc., we propose using [`main.sh`](https://bash3boilerplate.sh/main.sh) as a base and removing the parts you don't need.
|
||||
While this may feel a bit archaic at first, it is exactly the strength of Bash scripts that we should want to embrace.
|
||||
|
||||
**Portable**. We are targeting Bash 3 (OSX still ships
|
||||
@ -47,7 +45,7 @@ dependency.
|
||||
- Configuration by environment variables
|
||||
- Simple command-line argument parsing that requires no external dependencies. Definitions are parsed from help info, ensuring there will be no duplication
|
||||
- Helpful magic variables like `__file` and `__dir`
|
||||
- Logging that supports colors and is compatible with [Syslog Severity levels](http://en.wikipedia.org/wiki/Syslog#Severity_levels), as well as the [twelve-factor](http://12factor.net/) guidelines
|
||||
- Logging that supports colors and is compatible with [Syslog Severity levels](https://en.wikipedia.org/wiki/Syslog#Severity_levels), as well as the [twelve-factor](https://12factor.net/) guidelines
|
||||
|
||||
## Installation
|
||||
|
||||
@ -58,7 +56,7 @@ There are three different ways to install b3bp:
|
||||
Use curl or wget to download the source and save it as your script. Then you can start deleting the unwanted bits, and adding your own logic.
|
||||
|
||||
```bash
|
||||
wget http://bash3boilerplate.sh/main.sh
|
||||
wget https://bash3boilerplate.sh/main.sh
|
||||
vim main.sh
|
||||
```
|
||||
|
||||
@ -95,15 +93,14 @@ As of `v1.0.3`, b3bp offers some nice re-usable libraries in `./src`. In order t
|
||||
|
||||
### Function packaging
|
||||
|
||||
It is nice to have a Bash package that can not only be used in the terminal, but also invoked as a command line function. In order to achieve this, the exporting of your functionality *should* follow this pattern:
|
||||
It is nice to have a Bash package that can not only be used in the terminal, but also invoked as a command line function. In order to achieve this, the exporting of your functionality _should_ follow this pattern:
|
||||
|
||||
```bash
|
||||
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
|
||||
export -f my_script
|
||||
else
|
||||
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
|
||||
my_script "${@}"
|
||||
exit $?
|
||||
fi
|
||||
export -f my_script
|
||||
```
|
||||
|
||||
This allows a user to `source` your script or invoke it as a script.
|
||||
@ -116,7 +113,7 @@ $ source my_script.sh
|
||||
$ my_script some more args --blah
|
||||
```
|
||||
|
||||
(taken from the [bpkg](https://raw.githubusercontent.com/bpkg/bpkg/master/README.md) project)
|
||||
(taken from the [bpkg](https://raw.githubusercontent.com/bpkg/bpkg/HEAD/README.md) project)
|
||||
|
||||
### Scoping
|
||||
|
||||
@ -138,27 +135,27 @@ $ my_script some more args --blah
|
||||
1. Use `set`, rather than relying on a shebang like `#!/usr/bin/env bash -e`, since that is neutralized when someone runs your script as `bash yourscript.sh`.
|
||||
1. Use `#!/usr/bin/env bash`, as it is more portable than `#!/bin/bash`.
|
||||
1. Use `${BASH_SOURCE[0]}` if you refer to current file, even if it is sourced by a parent script. In other cases, use `${0}`.
|
||||
1. Use `:-` if you want to test variables that could be undeclared. For instance, with `if [ "${NAME:-}" = "Kevin" ]`, `$NAME` will evaluate to `Kevin` if the variable is empty. The variable itself will remain unchanged. The syntax to assign a default value is `${NAME:=Kevin}`.
|
||||
1. Use `:-` if you want to test variables that could be undeclared. For instance, with `if [[ "${NAME:-}" = "Kevin" ]]`, `$NAME` will evaluate to `Kevin` if the variable is empty. The variable itself will remain unchanged. The syntax to assign a default value is `${NAME:=Kevin}`.
|
||||
|
||||
## Who uses b3bp?
|
||||
|
||||
- [Transloadit](https://transloadit.com)
|
||||
- [OpenCoarrays](http://www.opencoarrays.org)
|
||||
- [Sourcery Institute](http://www.sourceryinstitute.org)
|
||||
- [Computational Brain Anatomy Laboratory](http://cobralab.ca/)
|
||||
- [OpenCoarrays](https://www.opencoarrays.org)
|
||||
- [Sourcery Institute](https://www.sourceryinstitute.org)
|
||||
- [Computational Brain Anatomy Laboratory](https://cobralab.ca/)
|
||||
- [Genesis Cloud](https://genesiscloud.com/)
|
||||
|
||||
We are looking for endorsements! Are you also using b3bp? [Let us know](https://github.com/kvz/bash3boilerplate/issues/new?title=I%20use%20b3bp) and get listed.
|
||||
|
||||
## Authors
|
||||
|
||||
- [Kevin van Zonneveld](http://kvz.io)
|
||||
- [Kevin van Zonneveld](https://kvz.io)
|
||||
- [Izaak Beekman](https://izaakbeekman.com/)
|
||||
- [Manuel Streuhofer](https://github.com/mstreuhofer)
|
||||
- [Alexander Rathai](mailto:Alexander.Rathai@gmail.com)
|
||||
- [Dr. Damian Rouson](http://www.sourceryinstitute.org/) (documentation, feedback)
|
||||
- [Dr. Damian Rouson](https://www.sourceryinstitute.org/) (documentation, feedback)
|
||||
- [@jokajak](https://github.com/jokajak) (documentation)
|
||||
- [Gabriel A. Devenyi](http://staticwave.ca/) (feedback)
|
||||
- [Gabriel A. Devenyi](https://staticwave.ca/) (feedback)
|
||||
- [@bravo-kernel](https://github.com/bravo-kernel) (feedback)
|
||||
- [@skanga](https://github.com/skanga) (feedback)
|
||||
- [galaktos](https://www.reddit.com/user/galaktos) (feedback)
|
||||
@ -167,10 +164,12 @@ We are looking for endorsements! Are you also using b3bp? [Let us know](https://
|
||||
- [Germain Masse](https://github.com/gmasse)
|
||||
- [A. G. Madi](https://github.com/warpengineer)
|
||||
- [Lukas Stockner](mailto:oss@genesiscloud.com)
|
||||
- [Gert Goet](https://github.com/eval)
|
||||
- [@rfuehrer](https://github.com/rfuehrer)
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2013 Kevin van Zonneveld and [contributors](https://github.com/kvz/bash3boilerplate#authors).
|
||||
Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/master/LICENSE).
|
||||
Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/HEAD/LICENSE).
|
||||
You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||
as you leave these references intact in the header comments of your source files.
|
||||
|
1
docs/CNAME
Normal file
@ -0,0 +1 @@
|
||||
bash3boilerplate.sh
|
15
docs/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
http-equiv="refresh"
|
||||
content="0;url=https://github.com/kvz/bash3boilerplate"
|
||||
/>
|
||||
<title>Redirecting...</title>
|
||||
</head>
|
||||
<body>
|
||||
If you are not redirected,
|
||||
<a href="https://github.com/kvz/bash3boilerplate">click here</a>.
|
||||
</body>
|
||||
</html>
|
13
example.sh
@ -61,8 +61,7 @@ trap __b3bp_cleanup_before_exit EXIT
|
||||
|
||||
# requires `set -o errtrace`
|
||||
__b3bp_err_report() {
|
||||
local error_code
|
||||
error_code=${?}
|
||||
local error_code=${?}
|
||||
# shellcheck disable=SC2154
|
||||
error "Error in ${__file} in function ${1} on line ${2}"
|
||||
exit ${error_code}
|
||||
@ -124,18 +123,16 @@ info "arg_f: ${arg_f}"
|
||||
info "arg_d: ${arg_d}"
|
||||
info "arg_v: ${arg_v}"
|
||||
info "arg_h: ${arg_h}"
|
||||
if [[ -v arg_i ]]
|
||||
then
|
||||
if [[ -n "${arg_i:-}" ]]; then
|
||||
info "arg_i: ${#arg_i[@]}"
|
||||
for input_file in "${arg_i[@]}"
|
||||
do
|
||||
for input_file in "${arg_i[@]}"; do
|
||||
info " - ${input_file}"
|
||||
done
|
||||
else
|
||||
info "arg_i: 0"
|
||||
fi
|
||||
# shellcheck disable=SC2015
|
||||
[[ -v arg_x ]] && info "arg_x: ${#arg_x[@]}" || info "arg_x: 0"
|
||||
[[ -n "${arg_x:-}" ]] && info "arg_x: ${#arg_x[@]}" || info "arg_x: 0"
|
||||
|
||||
info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - line #2\\nimagine logging the output of 'ls -al /path/'")"
|
||||
|
||||
@ -143,7 +140,7 @@ info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - lin
|
||||
debug "Info useful to developers for debugging the application, not useful during operations."
|
||||
info "Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required."
|
||||
notice "Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required."
|
||||
warning "Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time. This is a debug message"
|
||||
warning "Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time."
|
||||
error "Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time."
|
||||
critical "Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection."
|
||||
alert "Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection."
|
||||
|
53
main.sh
@ -7,7 +7,7 @@
|
||||
#
|
||||
# LOG_LEVEL=7 ./main.sh -f /tmp/x -d (change this for your script)
|
||||
#
|
||||
# Based on a template by BASH3 Boilerplate v2.3.0
|
||||
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||
# http://bash3boilerplate.sh/#authors
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
@ -203,13 +203,15 @@ while read -r __b3bp_tmp_line; do
|
||||
if [[ "${__b3bp_tmp_line}" =~ ^Default= ]] || [[ "${__b3bp_tmp_line}" =~ \.\ *Default= ]]; then
|
||||
# ignore default value if option does not have an argument
|
||||
__b3bp_tmp_varname="__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}"
|
||||
|
||||
if [[ "${!__b3bp_tmp_varname}" != "0" ]]; then
|
||||
# take default
|
||||
__b3bp_tmp_init="${__b3bp_tmp_line##*Default=}"
|
||||
# strip double quotes from default argument
|
||||
__b3bp_tmp_re='^"(.*)"$'
|
||||
if [[ "${__b3bp_tmp_init}" =~ ${__b3bp_tmp_re} ]]; then
|
||||
__b3bp_tmp_init="${BASH_REMATCH[1]}"
|
||||
else
|
||||
# strip single quotes from default argument
|
||||
__b3bp_tmp_re="^'(.*)'$"
|
||||
if [[ "${__b3bp_tmp_init}" =~ ${__b3bp_tmp_re} ]]; then
|
||||
__b3bp_tmp_init="${BASH_REMATCH[1]}"
|
||||
@ -223,6 +225,7 @@ while read -r __b3bp_tmp_line; do
|
||||
printf -v "__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}" '%s' "2"
|
||||
fi
|
||||
|
||||
# Init var with value unless it is an array / a repeatable
|
||||
__b3bp_tmp_varname="__b3bp_tmp_is_array_${__b3bp_tmp_opt:0:1}"
|
||||
[[ "${!__b3bp_tmp_varname}" = "0" ]] && printf -v "arg_${__b3bp_tmp_opt:0:1}" '%s' "${__b3bp_tmp_init}"
|
||||
done <<< "${__usage:-}"
|
||||
@ -271,12 +274,23 @@ if [[ "${__b3bp_tmp_opts:-}" ]]; then
|
||||
|
||||
__b3bp_tmp_varname="__b3bp_tmp_is_array_${__b3bp_tmp_opt:0:1}"
|
||||
if [[ "${!__b3bp_tmp_varname}" != "0" ]]; then
|
||||
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}[@]"
|
||||
|
||||
# repeatables
|
||||
# shellcheck disable=SC2016
|
||||
declare -a "${__b3bp_tmp_varname}"='("${!__b3bp_tmp_varname}" "${__b3bp_tmp_value}")'
|
||||
debug "cli arg ${__b3bp_tmp_varname} append ${__b3bp_tmp_value}"
|
||||
if [[ -z "${OPTARG}" ]]; then
|
||||
# repeatable flags, they increcemnt
|
||||
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}"
|
||||
debug "cli arg ${__b3bp_tmp_varname} = (${__b3bp_tmp_default}) -> ${!__b3bp_tmp_varname}"
|
||||
# shellcheck disable=SC2004
|
||||
__b3bp_tmp_value=$((${!__b3bp_tmp_varname} + 1))
|
||||
printf -v "${__b3bp_tmp_varname}" '%s' "${__b3bp_tmp_value}"
|
||||
else
|
||||
# repeatable args, they get appended to an array
|
||||
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}[@]"
|
||||
debug "cli arg ${__b3bp_tmp_varname} append ${__b3bp_tmp_value}"
|
||||
declare -a "${__b3bp_tmp_varname}"='("${!__b3bp_tmp_varname}" "${__b3bp_tmp_value}")'
|
||||
fi
|
||||
else
|
||||
# non-repeatables
|
||||
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}"
|
||||
__b3bp_tmp_default="${!__b3bp_tmp_varname}"
|
||||
|
||||
@ -285,6 +299,7 @@ if [[ "${__b3bp_tmp_opts:-}" ]]; then
|
||||
fi
|
||||
|
||||
printf -v "${__b3bp_tmp_varname}" '%s' "${__b3bp_tmp_value}"
|
||||
|
||||
debug "cli arg ${__b3bp_tmp_varname} = (${__b3bp_tmp_default}) -> ${!__b3bp_tmp_varname}"
|
||||
fi
|
||||
done
|
||||
@ -346,8 +361,7 @@ trap __b3bp_cleanup_before_exit EXIT
|
||||
|
||||
# requires `set -o errtrace`
|
||||
__b3bp_err_report() {
|
||||
local error_code
|
||||
error_code=${?}
|
||||
local error_code=${?}
|
||||
error "Error in ${__file} in function ${1} on line ${2}"
|
||||
exit ${error_code}
|
||||
}
|
||||
@ -404,18 +418,27 @@ info "arg_f: ${arg_f}"
|
||||
info "arg_d: ${arg_d}"
|
||||
info "arg_v: ${arg_v}"
|
||||
info "arg_h: ${arg_h}"
|
||||
if [[ -v arg_i ]]
|
||||
then
|
||||
info "arg_i: ${#arg_i[@]}"
|
||||
for input_file in "${arg_i[@]}"
|
||||
do
|
||||
|
||||
# shellcheck disable=SC2015
|
||||
if [[ -n "${arg_i:-}" ]] && declare -p arg_i 2> /dev/null | grep -q '^declare \-a'; then
|
||||
info "arg_i:"
|
||||
for input_file in "${arg_i[@]}"; do
|
||||
info " - ${input_file}"
|
||||
done
|
||||
elif [[ -n "${arg_i:-}" ]]; then
|
||||
info "arg_i: ${arg_i}"
|
||||
else
|
||||
info "arg_i: 0"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2015
|
||||
[[ -v arg_x ]] && info "arg_x: ${#arg_x[@]}" || info "arg_x: 0"
|
||||
if [[ -n "${arg_x:-}" ]] && declare -p arg_x 2> /dev/null | grep -q '^declare \-a'; then
|
||||
info "arg_x: ${#arg_x[@]}"
|
||||
elif [[ -n "${arg_x:-}" ]]; then
|
||||
info "arg_x: ${arg_x}"
|
||||
else
|
||||
info "arg_x: 0"
|
||||
fi
|
||||
|
||||
info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - line #2\\nimagine logging the output of 'ls -al /path/'")"
|
||||
|
||||
@ -423,7 +446,7 @@ info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - lin
|
||||
debug "Info useful to developers for debugging the application, not useful during operations."
|
||||
info "Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required."
|
||||
notice "Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required."
|
||||
warning "Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time. This is a debug message"
|
||||
warning "Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time."
|
||||
error "Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time."
|
||||
critical "Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection."
|
||||
alert "Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection."
|
||||
|
54
package.json
@ -1,47 +1,29 @@
|
||||
{
|
||||
"name": "bash3boilerplate",
|
||||
"description": "Copypastable templates to write better bash scripts",
|
||||
"version": "2.4.0",
|
||||
"version": "2.7.2",
|
||||
"packageManager": "yarn@3.6.0+sha224.19e47520fa56c6146388fdeb438d9dcf6630c3f277a2e1180995c3bb",
|
||||
"engines": {
|
||||
"node": ">= 18",
|
||||
"yarn": "3.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build:production": "LANYON_ENV=production lanyon build",
|
||||
"build": "lanyon build",
|
||||
"deploy": "lanyon deploy",
|
||||
"encrypt": "lanyon encrypt",
|
||||
"install:lanyon": "lanyon install",
|
||||
"lint": "shellcheck --shell=bash $(find . -name '*.sh' -maxdepth 2)",
|
||||
"release:major": "env SEMANTIC=major npm run release",
|
||||
"release:minor": "env SEMANTIC=minor npm run release",
|
||||
"release:patch": "env SEMANTIC=patch npm run release",
|
||||
"release": "npm version ${SEMANTIC:-patch} -m \"Release %s\" && npm run version:replace && git commit main.sh src/*.sh -m 'Update version' && git push && git push --tags && npm publish",
|
||||
"save:fixtures": "cross-env SAVE_FIXTURES=true npm run test",
|
||||
"serve:production": "LANYON_ENV=production lanyon serve",
|
||||
"start:production": "npm-run-all build:production serve:production",
|
||||
"start": "lanyon start",
|
||||
"lint:shellcheck": "shellcheck --severity=${SHELLCHECK_SEVERITY:-info} $(find . -name '*.sh' -maxdepth 2)",
|
||||
"lint:style": "test/style.pl $(find . -name '*.sh' -maxdepth 2)",
|
||||
"lint": "npm-run-all -l 'lint:**'",
|
||||
"release:major": "env SEMANTIC=major yarn release",
|
||||
"release:minor": "env SEMANTIC=minor yarn release",
|
||||
"release:patch": "env SEMANTIC=patch yarn release",
|
||||
"release": "npm version ${SEMANTIC:-patch} -m \"Release %s\" && yarn version:replace && git commit main.sh src/*.sh -m 'Update version' && git push && git push --tags -f && npm publish",
|
||||
"test:debug:main:repeated": "env LOG_LEVEL=7 test/acceptance.sh main-repeated",
|
||||
"test:update": "env SAVE_FIXTURES=true yarn test",
|
||||
"test": "test/acceptance.sh",
|
||||
"upgrade:modules": "next-update --keep true --tldr",
|
||||
"version:current": "node -e 'console.log(require(\"./package.json\").version)'",
|
||||
"version:replace": "replace 'v\\d+\\.\\d+\\.\\d+' \"v$(npm run --silent version:current)\" main.sh src/*.sh"
|
||||
},
|
||||
"lanyon": {
|
||||
"projectDir": "website",
|
||||
"prebuild": "./_scripts/inject.sh",
|
||||
"contentScandir": "../",
|
||||
"contentIgnore": [
|
||||
"website/*.md",
|
||||
"website/main.sh"
|
||||
]
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "*"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"browser-sync": "2.18.5",
|
||||
"cross-env": "3.1.3",
|
||||
"fakefile": "0.0.8",
|
||||
"lanyon": "0.0.92",
|
||||
"next-update": "1.5.1",
|
||||
"npm-run-all": "3.1.2",
|
||||
"replace": "^0.3.0"
|
||||
"fakefile": "1.1.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"replace": "1.2.2"
|
||||
}
|
||||
}
|
||||
|
@ -7,18 +7,19 @@
|
||||
#
|
||||
# Limitations:
|
||||
#
|
||||
# - All keys inside the .ini file must be unique, regardless of the use of sections
|
||||
# - All keys inside a section of the .ini file must be unique
|
||||
# - Optional comment parameter for the creation of new entries
|
||||
#
|
||||
# Usage as a function:
|
||||
#
|
||||
# source ini_val.sh
|
||||
# ini_val data.ini connection.host 127.0.0.1
|
||||
# ini_val data.ini connection.host 127.0.0.1 "Host name or IP address"
|
||||
#
|
||||
# Usage as a command:
|
||||
#
|
||||
# ini_val.sh data.ini connection.host 127.0.0.1
|
||||
# ini_val.sh data.ini connection.host 127.0.0.1 "Host name or IP address"
|
||||
#
|
||||
# Based on a template by BASH3 Boilerplate v2.3.0
|
||||
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||
# http://bash3boilerplate.sh/#authors
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
@ -30,43 +31,77 @@ function ini_val() {
|
||||
local file="${1:-}"
|
||||
local sectionkey="${2:-}"
|
||||
local val="${3:-}"
|
||||
local delim=" = "
|
||||
local comment="${4:-}"
|
||||
local delim="="
|
||||
local comment_delim=";"
|
||||
local section=""
|
||||
local key=""
|
||||
local current=""
|
||||
# add default section
|
||||
local section_default="default"
|
||||
|
||||
if [[ ! -f "${file}" ]]; then
|
||||
# touch file if not exists
|
||||
touch "${file}"
|
||||
fi
|
||||
|
||||
# Split on . for section. However, section is optional
|
||||
IFS='.' read -r section key <<< "${sectionkey}"
|
||||
if [[ ! "${key}" ]]; then
|
||||
key="${section}"
|
||||
section=""
|
||||
# default section if not given
|
||||
section="${section_default}"
|
||||
fi
|
||||
|
||||
local current
|
||||
current=$(awk -F "${delim}" "/^${key}${delim}/ {for (i=2; i<NF; i++) printf \$i \" \"; print \$NF}" "${file}")
|
||||
# get current value (if exists)
|
||||
current=$(sed -En "/^\[/{h;d;};G;s/^${key}([[:blank:]]*)${delim}(.*)\n\[${section}\]$/\2/p" "${file}"|awk '{$1=$1};1')
|
||||
# get current comment (if exists)
|
||||
current_comment=$(sed -En "/^\[${section}\]/,/^\[.*\]/ s|^(${comment_delim}\[${key}\])(.*)|\2|p" "${file}"|awk '{$1=$1};1')
|
||||
|
||||
if ! grep -q "\[${section}\]" "${file}"; then
|
||||
# create section if not exists (empty line to seperate new section for better readability)
|
||||
echo >> "${file}"
|
||||
echo "[${section}]" >> "${file}"
|
||||
fi
|
||||
|
||||
if [[ ! "${val}" ]]; then
|
||||
# get a value
|
||||
echo "${current}"
|
||||
else
|
||||
# set a value
|
||||
if [[ ! "${current}" ]]; then
|
||||
# doesn't exist yet, add
|
||||
|
||||
if [[ ! "${section}" ]]; then
|
||||
# no section was given, add to bottom of file
|
||||
echo "${key}${delim}${val}" >> "${file}"
|
||||
else
|
||||
# add to section
|
||||
sed -i.bak -e "/\\[${section}\\]/a ${key}${delim}${val}" "${file}"
|
||||
# this .bak dance is done for BSD/GNU portability: http://stackoverflow.com/a/22084103/151666
|
||||
rm -f "${file}.bak"
|
||||
fi
|
||||
else
|
||||
# replace existing
|
||||
sed -i.bak -e "/^${key}${delim}/s/${delim}.*/${delim}${val}/" "${file}"
|
||||
# this .bak dance is done for BSD/GNU portability: http://stackoverflow.com/a/22084103/151666
|
||||
rm -f "${file}.bak"
|
||||
if [[ ! "${section}" ]]; then
|
||||
# if no section is given, propagate the default section
|
||||
section=${section_default}
|
||||
fi
|
||||
|
||||
if [[ ! "${comment}" ]]; then
|
||||
# if no comment given, keep old comment
|
||||
comment="${current_comment}"
|
||||
fi
|
||||
# maintenance area
|
||||
# a) remove comment if new given / respect section
|
||||
sed -i.bak "/^\[${section}\]/,/^\[.*\]/ s|^\(${comment_delim}\[${key}\] \).*$||" "${file}"
|
||||
# b) remove old key / respect section
|
||||
sed -i.bak "/^\[${section}\]/,/^\[.*\]/ s|^\(${key}=\).*$||" "${file}"
|
||||
# c) remove all empty lines in ini file
|
||||
sed -i.bak '/^[[:space:]]*$/d' "${file}"
|
||||
# d) insert line break before every section for better readability
|
||||
sed -i.bak $'s/^\\[/\\\n\\[/g' "${file}"
|
||||
|
||||
# add to section
|
||||
if [[ ! "${comment}" ]]; then
|
||||
# add new key/value _without_ comment
|
||||
RET="/\\[${section}\\]/a\\
|
||||
${key}${delim}${val}"
|
||||
else
|
||||
# add new key/value _with_ preceeding comment
|
||||
RET="/\\[${section}\\]/a\\
|
||||
${comment_delim}[${key}] ${comment}\\
|
||||
${key}${delim}${val}"
|
||||
fi
|
||||
sed -i.bak -e "${RET}" "${file}"
|
||||
# this .bak dance is done for BSD/GNU portability: http://stackoverflow.com/a/22084103/151666
|
||||
rm -f "${file}.bak"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#
|
||||
# megamount.sh smb://janedoe:abc123@192.168.0.1/documents /mnt/documents
|
||||
#
|
||||
# Based on a template by BASH3 Boilerplate v2.3.0
|
||||
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||
# http://bash3boilerplate.sh/#authors
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#
|
||||
# parse_url.sh 'http://johndoe:abc123@example.com:8080/index.html'
|
||||
#
|
||||
# Based on a template by BASH3 Boilerplate v2.3.0
|
||||
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||
# http://bash3boilerplate.sh/#authors
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
|
@ -16,7 +16,7 @@
|
||||
#
|
||||
# ALLOW_REMAINDERS=1 templater.sh input.cfg output.cfg
|
||||
#
|
||||
# Based on a template by BASH3 Boilerplate v2.3.0
|
||||
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||
# http://bash3boilerplate.sh/#authors
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
|
@ -98,7 +98,7 @@ while IFS=$'\n' read -r scenario; do
|
||||
-e "s@${USER:-travis}@{user}@g" "${curFile}" \
|
||||
-e "s@travis@{user}@g" "${curFile}" \
|
||||
-e "s@kvz@{user}@g" "${curFile}" \
|
||||
-e "s@{root}/node_modules/\.bin/node@{node}@g" "${curFile}" \
|
||||
-e "s@{root}/node_modules/\\.bin/node@{node}@g" "${curFile}" \
|
||||
-e "s@{home}/build/{user}/fre{node}@{node}@g" "${curFile}" \
|
||||
-e "s@${HOSTNAME}@{hostname}@g" "${curFile}" \
|
||||
-e "s@${__arch}@{arch}@g" "${curFile}" \
|
||||
@ -198,6 +198,9 @@ done <<< "$(find "${__dir}/scenario" -type f -iname 'run.sh')"
|
||||
# shellcheck disable=SC2230
|
||||
# "command -v" is not a substitute for "which -a"
|
||||
while IFS=$'\n' read -r bash; do
|
||||
if [[ "${bash:-}" = "" ]]; then
|
||||
continue
|
||||
fi
|
||||
# shellcheck disable=SC2016
|
||||
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"
|
||||
pushd "${__root}" > /dev/null
|
||||
@ -206,7 +209,6 @@ while IFS=$'\n' read -r bash; do
|
||||
|
||||
while IFS=$'\n' read -r file; do
|
||||
[[ "${file}" =~ ^\./node_modules/ ]] && continue
|
||||
[[ "${file}" =~ ^\./website/\.lanyon/ ]] && continue
|
||||
|
||||
echo -n " ${file}.. "
|
||||
|
||||
@ -227,65 +229,4 @@ while IFS=$'\n' read -r bash; do
|
||||
fi
|
||||
done <<< "$(which -a bash 2>/dev/null)"
|
||||
|
||||
# do some shellcheck linting
|
||||
if [[ "$(command -v shellcheck)" ]]; then
|
||||
echo "==> Shellcheck"
|
||||
pushd "${__root}" > /dev/null
|
||||
|
||||
failed="false"
|
||||
|
||||
while IFS=$'\n' read -r file; do
|
||||
[[ "${file}" =~ ^\./node_modules/ ]] && continue
|
||||
[[ "${file}" =~ ^\./website/\.lanyon/ ]] && continue
|
||||
|
||||
echo -n " ${file}.. "
|
||||
|
||||
if ! shellcheck --shell=bash --external-sources --color=always \
|
||||
"${file}" >> "${__accptstTmpDir}/shellcheck.err"; then
|
||||
echo "✗"
|
||||
failed="true"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "✓"
|
||||
done <<< "$(find . -type f -iname '*.sh')"
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
if [[ "${failed}" = "true" ]]; then
|
||||
cat "${__accptstTmpDir}/shellcheck.err"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# poor man's style guide checking
|
||||
echo "==> b3bp style guide"
|
||||
pushd "${__root}" > /dev/null
|
||||
|
||||
failed="false"
|
||||
|
||||
while IFS=$'\n' read -r file; do
|
||||
[[ "${file}" =~ ^\./node_modules/ ]] && continue
|
||||
[[ "${file}" =~ ^\./website/\.lanyon/ ]] && continue
|
||||
|
||||
echo -n " ${file}.. "
|
||||
|
||||
if ! "${__root}/test/style.pl" "${file}" >> "${__accptstTmpDir}/style.err"; then
|
||||
echo "✗"
|
||||
failed="true"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "✓"
|
||||
done <<< "$(find . -type f -iname '*.sh')"
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
if [[ "${failed}" = "true" ]]; then
|
||||
echo
|
||||
cat "${__accptstTmpDir}/style.err"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -17,9 +17,9 @@ ACCPTST:STDIO_REPLACE_DATETIMES
|
||||
{datetime} UTC [35m[ debug][0m Info useful to developers for debugging the application, not useful during operations.
|
||||
{datetime} UTC [32m[ info][0m Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
||||
{datetime} UTC [34m[ notice][0m Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
||||
{datetime} UTC [33m[ warning][0m Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time. This is a debug message
|
||||
{datetime} UTC [33m[ warning][0m Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
||||
{datetime} UTC [31m[ error][0m Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
||||
{datetime} UTC [1;31m[ critical][0m Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection.
|
||||
{datetime} UTC [1;33;41m[ alert][0m Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||
{datetime} UTC [1;4;5;33;41m[emergency][0m A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||
{datetime} UTC [1;37;41m[ alert][0m Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||
{datetime} UTC [1;4;5;37;41m[emergency][0m A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||
{datetime} UTC [32m[ info][0m Cleaning up. Done
|
||||
|
@ -2,23 +2,41 @@
|
||||
exists
|
||||
127.0.0.1
|
||||
nginx, nodejs
|
||||
|
||||
--> command: Replace three values in-place and show result
|
||||
orphan = no more
|
||||
|
||||
[default]
|
||||
orphan=no more
|
||||
|
||||
[connection]
|
||||
host = 192.168.0.1
|
||||
host=192.168.0.1
|
||||
|
||||
[software]
|
||||
packages = vim
|
||||
packages=vim
|
||||
|
||||
[comment]
|
||||
;[command] got this new comment
|
||||
command=works like a chame
|
||||
;[new_command] last addition will be moved downwards again after next command
|
||||
new_command=commented too
|
||||
--> function: Read 3 values
|
||||
exists
|
||||
127.0.0.1
|
||||
nginx, nodejs
|
||||
|
||||
--> function: Replace three values in-place and show result
|
||||
orphan = no more
|
||||
|
||||
[default]
|
||||
orphan=no more
|
||||
|
||||
[connection]
|
||||
host = 192.168.0.1
|
||||
host=192.168.0.1
|
||||
|
||||
[software]
|
||||
packages = vim
|
||||
packages=vim
|
||||
|
||||
[comment]
|
||||
;[command] got this new comment
|
||||
command=works like a chame
|
||||
;[new_command] last addition will be moved downwards again after next command
|
||||
new_command=commented too
|
||||
|
@ -17,9 +17,9 @@ ACCPTST:STDIO_REPLACE_DATETIMES
|
||||
{datetime} UTC [35m[ debug][0m Info useful to developers for debugging the application, not useful during operations.
|
||||
{datetime} UTC [32m[ info][0m Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
||||
{datetime} UTC [34m[ notice][0m Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
||||
{datetime} UTC [33m[ warning][0m Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time. This is a debug message
|
||||
{datetime} UTC [33m[ warning][0m Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
||||
{datetime} UTC [31m[ error][0m Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
||||
{datetime} UTC [1;31m[ critical][0m Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection.
|
||||
{datetime} UTC [1;33;41m[ alert][0m Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||
{datetime} UTC [1;4;5;33;41m[emergency][0m A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||
{datetime} UTC [1;37;41m[ alert][0m Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||
{datetime} UTC [1;4;5;37;41m[emergency][0m A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||
{datetime} UTC [32m[ info][0m Cleaning up. Done
|
||||
|
@ -17,7 +17,7 @@ ACCPTST:STDIO_REPLACE_DATETIMES
|
||||
{datetime} UTC [ debug] Info useful to developers for debugging the application, not useful during operations.
|
||||
{datetime} UTC [ info] Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
||||
{datetime} UTC [ notice] Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
||||
{datetime} UTC [ warning] Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time. This is a debug message
|
||||
{datetime} UTC [ warning] Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
||||
{datetime} UTC [ error] Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
||||
{datetime} UTC [ critical] Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection.
|
||||
{datetime} UTC [ alert] Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||
|
@ -1,5 +1,5 @@
|
||||
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||
{datetime} UTC [32m[ info][0m arg_i: 5
|
||||
{datetime} UTC [32m[ info][0m arg_i:
|
||||
{datetime} UTC [32m[ info][0m - simple_input
|
||||
{datetime} UTC [32m[ info][0m - input_in_quotes
|
||||
{datetime} UTC [32m[ info][0m - input with spaces
|
||||
|
@ -1,7 +1,8 @@
|
||||
orphan = exists
|
||||
[default]
|
||||
orphan=exists
|
||||
|
||||
[connection]
|
||||
host = 127.0.0.1
|
||||
host=127.0.0.1
|
||||
|
||||
[software]
|
||||
packages = nginx, nodejs
|
||||
packages=nginx, nodejs
|
||||
|
10
test/scenario/ini_val/run.sh
Normal file → Executable file
@ -17,11 +17,16 @@ echo "--> command: Read 3 values"
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini orphan
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini connection.host
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini software.packages
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.command
|
||||
|
||||
echo "--> command: Replace three values in-place and show result"
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini orphan "no more"
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini connection.host "192.168.0.1"
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini software.packages "vim"
|
||||
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.command "commented" "this key is commented"
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.new_command "commented too" "last addition will be moved downwards again after next command"
|
||||
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.command "works like a chame" "got this new comment"
|
||||
cat dummy.ini
|
||||
rm -f dummy.ini
|
||||
|
||||
@ -35,10 +40,15 @@ echo "--> function: Read 3 values"
|
||||
ini_val ./dummy.ini orphan
|
||||
ini_val ./dummy.ini connection.host
|
||||
ini_val ./dummy.ini software.packages
|
||||
ini_val ./dummy.ini comment.command
|
||||
|
||||
echo "--> function: Replace three values in-place and show result"
|
||||
ini_val ./dummy.ini orphan "no more"
|
||||
ini_val ./dummy.ini connection.host "192.168.0.1"
|
||||
ini_val ./dummy.ini software.packages "vim"
|
||||
|
||||
ini_val ./dummy.ini comment.command "commented" "this key is commited"
|
||||
ini_val ./dummy.ini comment.new_command "commented too" "last addition will be moved downwards again after next command"
|
||||
ini_val ./dummy.ini comment.command "works like a chame" "got this new comment"
|
||||
cat dummy.ini
|
||||
rm -f dummy.ini
|
||||
|
@ -10,10 +10,10 @@ __root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||
|
||||
(
|
||||
env LOG_LEVEL=6 bash "${__root}/main.sh" -f dummy -i simple_input -i "input_in_quotes" -i "input with spaces" -i "input with \"quotes\"" -i last_input
|
||||
env LOG_LEVEL="${LOG_LEVEL:-6}" bash "${__root}/main.sh" -f dummy -i simple_input -i "input_in_quotes" -i "input with spaces" -i "input with \"quotes\"" -i last_input
|
||||
) 2>&1 |grep arg_i -A 5
|
||||
|
||||
(
|
||||
env LOG_LEVEL=6 bash "${__root}/main.sh" -x -f dummy -x -x
|
||||
env LOG_LEVEL=6 bash "${__root}/main.sh" -f dummy -xxxx
|
||||
env LOG_LEVEL="${LOG_LEVEL:-6}" bash "${__root}/main.sh" -x -f dummy -x -x
|
||||
env LOG_LEVEL="${LOG_LEVEL:-6}" bash "${__root}/main.sh" -f dummy -xxxx
|
||||
) 2>&1 |grep arg_x
|
||||
|
@ -1 +0,0 @@
|
||||
{rules: {}}
|
@ -1 +0,0 @@
|
||||
bash3boilerplate.sh
|
@ -1,4 +0,0 @@
|
||||
title: BASH3 Boilerplate
|
||||
|
||||
gems:
|
||||
- jekyll-redirect-from
|
@ -1,84 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
{% if page.url == "/" %}
|
||||
<title>{{page.title}}</title>
|
||||
{% else %}
|
||||
<title>{{page.title}} | {{site.title}}</title>
|
||||
{% endif %}
|
||||
|
||||
<meta name="keywords" content="bash, template, scripting, command-line">
|
||||
<meta name="description" content="BASH3 Boilerplate">
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{{site.lanyon_assets.app.css}}" media="screen" charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div id="header-overlay"></div>
|
||||
<a href="/">
|
||||
<span id="logo"></span>
|
||||
</a>
|
||||
<div id="menu">
|
||||
<i class="material-icons">menu</i>
|
||||
<ul id="menu-items">
|
||||
</ul>
|
||||
</div>
|
||||
<span id="more">
|
||||
<i class="material-icons">expand_more</i>
|
||||
</span>
|
||||
</header>
|
||||
<section id="content">
|
||||
{% if page.url == "/" %}
|
||||
<div class="Social">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=kvz&repo=bash3boilerplate&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://travis-ci.org/kvz/bash3boilerplate"><img src="https://travis-ci.org/kvz/bash3boilerplate.svg" alt="Build Status"></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{content}}
|
||||
|
||||
{% if page.url == "/" %}
|
||||
<h2 id="activity-feed">On GitHub</h2>
|
||||
<p>
|
||||
BASH3 Boilerplate is a friendly group of folks further developing our
|
||||
re-usable templates as we go.
|
||||
We'd love to hear what you think <a href="https://github.com/kvz/bash3boilerplate">on GitHub</a>.
|
||||
Here's what's been going on recently.
|
||||
</p>
|
||||
<div class="on-the-githubs" data-event-source="repos/kvz/bash3boilerplate">Loading...</div>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script src="//kvz.github.io/on-the-githubs/js/jquery.on-the-githubs.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$('.on-the-githubs').onthegithubs();
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<div class="Social">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=kvz&repo=bash3boilerplate&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<small>
|
||||
<hr />
|
||||
Website design based on
|
||||
the wonderful <a href="http://apex.run">apex.run</a>
|
||||
with <a href="https://twitter.com/tjholowaychuk/status/744909762865696769">the author's consent</a>.
|
||||
</small>
|
||||
</p>
|
||||
</section>
|
||||
</body>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/languages/bash.min.js"></script>
|
||||
<script async src="{{site.lanyon_assets.app.js}}"></script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-63083-13', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</html>
|
@ -1,76 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This file:
|
||||
#
|
||||
# - Injects markdown files into the ./website directory
|
||||
# - Changes them a little to make them more suitable for Jekyll building
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# ./inject.sh
|
||||
#
|
||||
# Based on a template by BASH3 Boilerplate v2.0.0
|
||||
# http://bash3boilerplate.sh/#authors
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||
# as you leave these references intact in the header comments of your source files.
|
||||
|
||||
# Exit on error. Append || true if you expect an error.
|
||||
set -o errexit
|
||||
# Exit on error inside any functions or subshells.
|
||||
set -o errtrace
|
||||
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
|
||||
set -o nounset
|
||||
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
|
||||
set -o pipefail
|
||||
# Turn on traces, useful while debugging but commented out by default
|
||||
# set -o xtrace
|
||||
|
||||
# Set magic variables for current file, directory, os, etc.
|
||||
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
|
||||
__base="$(basename "${__file}" .sh)"
|
||||
__root="$(cd "$(dirname "$(dirname "${__dir}")")" && pwd)"
|
||||
|
||||
pushd "${__root}"
|
||||
# Offer the main template for download as http://bash3boilerplate.sh/main.sh
|
||||
cp -v main.sh website/
|
||||
|
||||
for doc in "README" "FAQ" "CHANGELOG"; do
|
||||
targetName="$(echo "${doc}" | awk '{print tolower($0)}')"
|
||||
permalink="/${targetName}/"
|
||||
subtitle="$(tr '[:lower:]' '[:upper:]' <<< "${targetName:0:1}")${targetName:1} | "
|
||||
redirectFrom="/${doc}.md/"
|
||||
backLink='\n\n<a href="/">« Home</a>'
|
||||
if [[ "${doc}" = "README" ]]; then
|
||||
targetName="index"
|
||||
permalink="/"
|
||||
subtitle=""
|
||||
redirectFrom="nothing"
|
||||
backLink=""
|
||||
fi
|
||||
|
||||
cat <<EOF > "website/${targetName}.md"
|
||||
---
|
||||
layout: default
|
||||
permalink: ${permalink}
|
||||
redirect_from: ${redirectFrom}
|
||||
title: ${subtitle}BASH3 Boilerplate – Template for writing better Bash scripts
|
||||
warning: This page is generated by ${__base}.sh based on ${doc}.md, please don't edit ${targetName}.md directly.
|
||||
---
|
||||
EOF
|
||||
# If '<!--more-->' exists, only inject what comes after it, so you can have e.g. a ToC or buildbuttons
|
||||
# on GitHub, without that also rendering in the site (site may have its own ToC rendering for instance)
|
||||
if grep '<!--more-->' "${doc}.md"; then
|
||||
sed -n -e '/<!--more-->/,$p' "${doc}.md" | tail -n +2 >> "website/${targetName}.md"
|
||||
else
|
||||
cat "${doc}.md" >> "website/${targetName}.md"
|
||||
fi
|
||||
|
||||
# Add a "<- Back Home" link, if any
|
||||
echo -e "${backLink}" >> "website/${targetName}.md"
|
||||
|
||||
echo "--> written website/${targetName}.md"
|
||||
done
|
||||
popd
|
@ -1,13 +0,0 @@
|
||||
require('./main.js')
|
||||
require('./style.css')
|
||||
require('./syntax.css')
|
||||
|
||||
// check if HMR is enabled
|
||||
if (module.hot) {
|
||||
module.hot.accept('./main.js', function () {
|
||||
require('./main.js');
|
||||
});
|
||||
module.hot.accept('./style.css', function () {
|
||||
require('./style.css');
|
||||
});
|
||||
}
|
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 563 KiB |
Before Width: | Height: | Size: 349 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 543 KiB |
Before Width: | Height: | Size: 345 KiB |
@ -1,55 +0,0 @@
|
||||
// Backgrounds.
|
||||
// var backgrounds = [1,2,3,4,5,6]
|
||||
var backgrounds = [1]
|
||||
|
||||
// Highlighting.
|
||||
hljs.initHighlighting()
|
||||
|
||||
// Storage.
|
||||
var store = window.sessionStorage
|
||||
|
||||
// Background.
|
||||
var background = store.getItem('background')
|
||||
|
||||
if (!background) {
|
||||
var i = Math.random() * backgrounds.length | 0
|
||||
background = backgrounds[i]
|
||||
console.log('setting background to %s', background)
|
||||
store.setItem('background', background)
|
||||
}
|
||||
|
||||
// Body class for background.
|
||||
var el = document.getElementById('header-overlay')
|
||||
el.style.backgroundImage = 'url(/assets/images/' + background + '.jpg)'
|
||||
|
||||
// Attach class to #menu element depending on page offset.
|
||||
document.addEventListener('DOMContentLoaded', chooseMenuColor)
|
||||
window.onscroll = chooseMenuColor
|
||||
|
||||
function chooseMenuColor() {
|
||||
var menuElement = document.getElementById('menu')
|
||||
var menuTopOffset = 45
|
||||
Math.floor(window.innerHeight * .20) < window.pageYOffset + menuTopOffset ?
|
||||
menuElement.classList.remove('over-header') :
|
||||
menuElement.classList.add('over-header')
|
||||
}
|
||||
|
||||
|
||||
function $get(selector) { return document.querySelector(selector) }
|
||||
function $all(selector) {
|
||||
return Array.prototype.slice.call(document.querySelectorAll(selector))
|
||||
}
|
||||
|
||||
var container = $get('#menu-items')
|
||||
|
||||
// if (location.pathname !== '/') {
|
||||
// var li = document.createElement('li');
|
||||
// li.innerHTML = '<a href="/">« Home</a>';
|
||||
// container.appendChild(li);
|
||||
// }
|
||||
|
||||
$all('#content h2').forEach(function(el) {
|
||||
var li = document.createElement('li');
|
||||
li.innerHTML = '<a href="#' + el.id + '">' + el.innerHTML + '</a>';
|
||||
container.appendChild(li);
|
||||
})
|
@ -1,345 +0,0 @@
|
||||
|
||||
body {
|
||||
font: 16px/1.625 "Open Sans", "Helvetica Neue", "Helvetica", Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
color: #656a71;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#header-overlay {
|
||||
background: #131313 50% 100% no-repeat;
|
||||
background-size: cover;
|
||||
height: 20vh;
|
||||
width: 100%;
|
||||
opacity: 0;
|
||||
-webkit-animation-name: overlay;
|
||||
animation-name: overlay;
|
||||
-webkit-animation-duration: 5s;
|
||||
animation-duration: 5s;
|
||||
-webkit-animation-delay: 1s;
|
||||
animation-delay: 1s;
|
||||
-webkit-animation-fill-mode: forwards;
|
||||
animation-fill-mode: forwards;
|
||||
}
|
||||
|
||||
@-webkit-keyframes overlay {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: .25;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes overlay {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: .25;
|
||||
}
|
||||
}
|
||||
|
||||
body.background-1 #header-overlay {
|
||||
background-image: url(images/1.jpg);
|
||||
}
|
||||
|
||||
body.background-4 #header-overlay {
|
||||
background-image: url(images/1.jpg);
|
||||
}
|
||||
|
||||
#logo {
|
||||
display: block;
|
||||
background: url(images/b3bp-logo.png) center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
width: 180px;
|
||||
height: 120px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-left: -100px;
|
||||
margin-top: -60px;
|
||||
-webkit-animation-name: logo;
|
||||
animation-name: logo;
|
||||
-webkit-animation-duration: 2s;
|
||||
animation-duration: 2s;
|
||||
-webkit-animation-fill-mode: forwards;
|
||||
animation-fill-mode: forwards;
|
||||
}
|
||||
|
||||
@-webkit-keyframes logo {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes logo {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#more {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
color: white;
|
||||
opacity: 0;
|
||||
-webkit-animation-name: move;
|
||||
animation-name: move;
|
||||
-webkit-animation-duration: 3s;
|
||||
animation-duration: 3s;
|
||||
-webkit-animation-delay: 3s;
|
||||
animation-delay: 3s;
|
||||
-webkit-animation-fill-mode: forwards;
|
||||
animation-fill-mode: forwards;
|
||||
-webkit-animation-timing-function: cubic-bezier(0.86, 0, 0.07, 1);
|
||||
animation-timing-function: cubic-bezier(0.86, 0, 0.07, 1);
|
||||
}
|
||||
|
||||
@-webkit-keyframes move {
|
||||
0% {
|
||||
opacity: 0;
|
||||
bottom: 300px;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
90% {
|
||||
opacity: 1;
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
bottom: -10px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes move {
|
||||
0% {
|
||||
opacity: 0;
|
||||
bottom: 300px;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
90% {
|
||||
opacity: 1;
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
bottom: -10px;
|
||||
}
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 100px 0;
|
||||
max-width: 650px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#menu {
|
||||
position: fixed;
|
||||
top: 35px;
|
||||
right: 35px;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
color: black;
|
||||
padding: 7px;
|
||||
border-radius: 1px;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
#menu.over-header {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#menu i {
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
#menu:hover #menu-items {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
#menu-items {
|
||||
line-height: 1.7;
|
||||
opacity: 0;
|
||||
position: fixed;
|
||||
visibility: hidden;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
font-size: 12px;
|
||||
background: white;
|
||||
color: #121212;
|
||||
top: 67px;
|
||||
right: 35px;
|
||||
border-radius: 1px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#menu-items li a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#menu-items li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#menu-items li a {
|
||||
color: #4C4C4C;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4 {
|
||||
font-weight: 600;
|
||||
margin-bottom: 0px;
|
||||
color: #3b444f;
|
||||
}
|
||||
|
||||
h1 { font-size: 2em; /* 2*16 = 32 */ }
|
||||
h2 { font-size: 1.5em; /* 1.5*16 = 24 */ }
|
||||
h3 { font-size: 1.17em; /* 1.17*16 = 18.72 */ }
|
||||
h4 { font-size: 1em; /* 1*16 = 16 */ }
|
||||
h5 { font-size: 0.83em; /* 0.83*16 = 13.28 */ }
|
||||
h6 { font-size: 0.75em; /* 0.75*16 = 12 */ }
|
||||
|
||||
h1 {
|
||||
/*margin-top: 75px;*/
|
||||
}
|
||||
|
||||
h1::before {
|
||||
/*display: block;
|
||||
content: ' ';
|
||||
border-top: 1px dotted #eee;
|
||||
width: 35%;
|
||||
margin: 0 auto 75px auto;*/
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
p > code,
|
||||
li > code {
|
||||
border: 1px solid #eee;
|
||||
padding: 2px 10px;
|
||||
border-radius: 3px;
|
||||
font-size: .75rem;
|
||||
color: #555;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
header {
|
||||
background: #131313;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #55A1E1;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 1px;
|
||||
border: none;
|
||||
height: 1px;
|
||||
/* Set the hr color */
|
||||
color: gainsboro; /* old IE */
|
||||
background-color: gainsboro; /* Modern Browsers */
|
||||
}
|
||||
|
||||
.Social {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
.Social > * {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.on-the-githubs {
|
||||
-webkit-margin-before: 1em;
|
||||
-webkit-margin-after: 1em;
|
||||
}
|
||||
.on-the-githubs:after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
.on-the-githubs > li {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
/*height: 26px;*/
|
||||
position: relative;
|
||||
border-bottom: 1px solid rgba(gainsboro, 0.3);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.on-the-githubs > li:after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.on-the-githubs > li p {
|
||||
font-size: 15px;
|
||||
line-height: 16px;
|
||||
margin: 0 2px;
|
||||
padding: 0;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
overflow: hidden;
|
||||
max-width: 80%;
|
||||
}
|
||||
.on-the-githubs > li abbr {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
float: left;
|
||||
text-align: right;
|
||||
/*display: none*/
|
||||
}
|
||||
.on-the-githubs > li a {
|
||||
font-weight: normal;
|
||||
/*text-decoration: underline;*/
|
||||
}
|
||||
.on-the-githubs > li img {
|
||||
float: left;
|
||||
margin: 0 2px 0 0;
|
||||
border-radius: 10px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
|
||||
pre {
|
||||
border-top-color: #ddd;
|
||||
border-radius: 3px;
|
||||
font-size: .75rem;
|
||||
overflow-x: auto;
|
||||
line-height: 1.3;
|
||||
padding: 1.5rem;
|
||||
background: #fff;
|
||||
color: #333;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #eee;
|
||||
border-bottom-color: #ddd;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
XCode style (c) Angel Garcia <angelgarcia.mail@gmail.com>
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #006a00;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-literal {
|
||||
color: #aa0d91;
|
||||
}
|
||||
|
||||
.hljs-name {
|
||||
color: #008;
|
||||
}
|
||||
|
||||
.hljs-variable,
|
||||
.hljs-template-variable {
|
||||
color: #660;
|
||||
}
|
||||
|
||||
.hljs-string {
|
||||
color: #c41a16;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-link {
|
||||
color: #080;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-tag,
|
||||
.hljs-symbol,
|
||||
.hljs-bullet,
|
||||
.hljs-number,
|
||||
.hljs-meta {
|
||||
color: #1c00cf;
|
||||
}
|
||||
|
||||
.hljs-section,
|
||||
.hljs-class .hljs-title,
|
||||
.hljs-type,
|
||||
.hljs-attr,
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name,
|
||||
.hljs-params {
|
||||
color: #5c2699;
|
||||
}
|
||||
|
||||
.hljs-attribute,
|
||||
.hljs-subst {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.hljs-formula {
|
||||
background-color: #eee;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-addition {
|
||||
background-color: #baeeba;
|
||||
}
|
||||
|
||||
.hljs-deletion {
|
||||
background-color: #ffc8bd;
|
||||
}
|
||||
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-class {
|
||||
color: #9b703f;
|
||||
}
|
||||
|
||||
.hljs-doctag,
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|