Deploying to gh-pages from @ a2b2b49b0c5bcc065bdd1520b061683cf4d5b9cc 🚀

This commit is contained in:
kvz 2020-11-23 18:55:53 +00:00
parent 7fd386a584
commit 413e27c9a7
12 changed files with 83 additions and 291 deletions

View File

@ -1 +0,0 @@
This branch is just a deploy target. Do not edit. You changes will be lost.

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,2 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/assets/build/",n(n.s=0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";n(2),n(3),n(4)},function(e,t,n){"use strict";var r=[1];hljs.initHighlighting();var o=window.sessionStorage,u=o.getItem("background");u||(u=r[Math.random()*r.length|0],console.log("setting background to %s",u),o.setItem("background",u));function i(){var e=document.getElementById("menu");Math.floor(.2*window.innerHeight)<window.pageYOffset+45?e.classList.remove("over-header"):e.classList.add("over-header")}document.getElementById("header-overlay").style.backgroundImage="url(/assets/images/"+u+".jpg)",document.addEventListener("DOMContentLoaded",i),window.onscroll=i;var a,c=(a="#menu-items",document.querySelector(a));(function(e){return Array.prototype.slice.call(document.querySelectorAll(e))})("#content h2").forEach((function(e){var t=document.createElement("li");t.innerHTML='<a href="#'+e.id+'">'+e.innerHTML+"</a>",c.appendChild(t)}))},function(e,t,n){},function(e,t,n){}]);
//# sourceMappingURL=app.5c7edb9a417afd6fed50.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="/assets/build/",n(n.s=0)}([function(e,n,t){e.exports=t(1)},function(e,n,t){"use strict";t(2),t(3),t(4)},function(e,n,t){"use strict";function r(){var e=document.getElementById("menu");Math.floor(.2*window.innerHeight)<window.pageYOffset+45?e.classList.remove("over-header"):e.classList.add("over-header")}var o=[1];hljs.initHighlighting();var i=window.sessionStorage,u=i.getItem("background");if(!u){u=o[Math.random()*o.length|0],console.log("setting background to %s",u),i.setItem("background",u)}document.getElementById("header-overlay").style.backgroundImage="url(/assets/images/"+u+".jpg)",document.addEventListener("DOMContentLoaded",r),window.onscroll=r;var c=function(e){return document.querySelector(e)}("#menu-items");(function(e){return Array.prototype.slice.call(document.querySelectorAll(e))})("#content h2").forEach(function(e){var n=document.createElement("li");n.innerHTML='<a href="#'+e.id+'">'+e.innerHTML+"</a>",c.appendChild(n)})},function(e,n){},function(e,n){}]);
//# sourceMappingURL=app.a6d50511e193d4224561.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@
<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="/assets/build/app.a6d50511e193d4224561.css" media="screen" charset="utf-8">
<link href="/assets/build/app.651a09ef8a9b4bbd05bb.css" rel="stylesheet">
</head>
<body>
<header>
@ -32,7 +32,7 @@
<h1 id="changelog">Changelog</h1>
<p>Heres is a combined todo/done list. You can see what todos are planned for the upcoming release, as well as ideas that may/may not make into a release in <code class="highlighter-rouge">Ideas</code>.</p>
<p>Heres is a combined todo/done list. You can see what todos are planned for the upcoming release, as well as ideas that may/may not make into a release in <code class="language-plaintext highlighter-rouge">Ideas</code>.</p>
<h2 id="ideas">Ideas</h2>
@ -57,7 +57,7 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v2.4.1...v2.4.2">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Upgrade to <code class="highlighter-rouge">lanyon@0.1.16</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Upgrade to <code class="language-plaintext highlighter-rouge">lanyon@0.1.16</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Capture correct error_code in err_report (#124, @eval)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Enhanced ini file handling: create new file, create new sections, handle default section, read key from given section (@rfuehrer)</li>
</ul>
@ -68,11 +68,11 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.1">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Upgrade to <code class="highlighter-rouge">lanyon@0.1.7</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Upgrade to <code class="language-plaintext highlighter-rouge">lanyon@0.1.7</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow counting how many times an argument is used (@genesiscloud)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Fix typos in megamount (thanks @gsaponaro)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Enable color in screen or tmux (#92, @gmasse)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Change <code class="highlighter-rouge">egrep</code> to <code class="highlighter-rouge">grep -E</code> in test and lib scripts to comply with ShellCheck (#92, @gmasse)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Change <code class="language-plaintext highlighter-rouge">egrep</code> to <code class="language-plaintext highlighter-rouge">grep -E</code> in test and lib scripts to comply with ShellCheck (#92, @gmasse)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Fix typo in FAQ (#92, @gmasse)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Fix Travis CI failure on src/templater.sh (@gmasse)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add magic variable which contains full command invocation</li>
@ -87,7 +87,7 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.0">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Upgrade to <code class="highlighter-rouge">lanyon@0.0.143</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Upgrade to <code class="language-plaintext highlighter-rouge">lanyon@0.0.143</code></li>
</ul>
<h2 id="v230">v2.3.0</h2>
@ -96,11 +96,11 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v2.2.0...v2.3.0">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add magic variable <code class="highlighter-rouge">__i_am_main_script</code> to distinguish if b3bp is being sourced or called directly (#45, @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add magic variable <code class="language-plaintext highlighter-rouge">__i_am_main_script</code> to distinguish if b3bp is being sourced or called directly (#45, @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add style checks for tab characters and trailing whitespace (@zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add backtracing to help localize errors (#44, @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Additional FAQ entries (#47, suggested by @gdevenyi, implemented by @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Ensure that shifting over <code class="highlighter-rouge">--</code> doesnt throw an errexit error (#21, @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Ensure that shifting over <code class="language-plaintext highlighter-rouge">--</code> doesnt throw an errexit error (#21, @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add Pull Request template (#83)</li>
</ul>
@ -117,14 +117,14 @@
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Cleanup environment variables (#58, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Support multi-line logs (#57, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Run shellcheck as part of the acceptance test (#79, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Brace all variables, used <code class="highlighter-rouge">[[</code> instead of <code class="highlighter-rouge">[</code> (#33, #76, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Brace all variables, used <code class="language-plaintext highlighter-rouge">[[</code> instead of <code class="language-plaintext highlighter-rouge">[</code> (#33, #76, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add automatic usage validation for required args (#22, #65, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Remove all usage of eval (@mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Get rid of awk, sed &amp; egrep usage (#71, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Fix auto-color-off code (#69, #70, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Use shellcheck to find and fix unclean code (#68, #80, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow for multiline opt description in <code class="highlighter-rouge">__usage</code> (#7, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow <code class="highlighter-rouge">__usage</code> and <code class="highlighter-rouge">__helptext</code> to be defined before sourcing <code class="highlighter-rouge">main.sh</code> thus makeing b3bp behave like a library (@mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow for multiline opt description in <code class="language-plaintext highlighter-rouge">__usage</code> (#7, @mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow <code class="language-plaintext highlighter-rouge">__usage</code> and <code class="language-plaintext highlighter-rouge">__helptext</code> to be defined before sourcing <code class="language-plaintext highlighter-rouge">main.sh</code> thus makeing b3bp behave like a library (@mstreuhofer)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add the same License text to each script header (@mstreuhofer)</li>
</ul>
@ -145,12 +145,12 @@
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />For delete-key-friendliness, bundle the commandline definition block along with its parser</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Less verbose header comments</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />For delete-key-friendliness, dont crash on undeclared help vars</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Introduce <code class="highlighter-rouge">errtrace</code>, which is on by default (BREAKING)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add a configurable <code class="highlighter-rouge">helptext</code> that is left alone by the parses and allows you to have a richer help</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Introduce <code class="language-plaintext highlighter-rouge">errtrace</code>, which is on by default (BREAKING)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add a configurable <code class="language-plaintext highlighter-rouge">helptext</code> that is left alone by the parses and allows you to have a richer help</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add a simple documentation website</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add best practice of using <code class="highlighter-rouge">__double_underscore_prefixed_vars</code> to indicate global variables that are solely controlled inside your script</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add best practice of using <code class="language-plaintext highlighter-rouge">__double_underscore_prefixed_vars</code> to indicate global variables that are solely controlled inside your script</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Make license more permissive by not requiring distribution of the LICENSE file if the copyright &amp; attribution comments are left intact</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Respect <code class="highlighter-rouge">--no-color</code> by setting the <code class="highlighter-rouge">NO_COLOR</code> flag in <code class="highlighter-rouge">main.sh</code> (#25, thx @gdevenyi)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Respect <code class="language-plaintext highlighter-rouge">--no-color</code> by setting the <code class="language-plaintext highlighter-rouge">NO_COLOR</code> flag in <code class="language-plaintext highlighter-rouge">main.sh</code> (#25, thx @gdevenyi)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Split out changelog into separate file</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Added a <a href="./FAQ.md">FAQ</a> (#15, #14, thanks @rouson)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Fix Travis OSX testing (before, it would silently pass failures) (#10)</li>
@ -163,12 +163,12 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v1.2.1...v2.0.0">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="highlighter-rouge">templater</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="highlighter-rouge">ini_val</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="highlighter-rouge">parse_url</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="highlighter-rouge">megamount</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Remove <code class="highlighter-rouge">bump</code> from <code class="highlighter-rouge">src</code> (BREAKING)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Remove <code class="highlighter-rouge">semver</code> from <code class="highlighter-rouge">src</code> (BREAKING)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="language-plaintext highlighter-rouge">templater</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="language-plaintext highlighter-rouge">ini_val</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="language-plaintext highlighter-rouge">parse_url</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add tests for <code class="language-plaintext highlighter-rouge">megamount</code> and follow Library export best practices</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Remove <code class="language-plaintext highlighter-rouge">bump</code> from <code class="language-plaintext highlighter-rouge">src</code> (BREAKING)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Remove <code class="language-plaintext highlighter-rouge">semver</code> from <code class="language-plaintext highlighter-rouge">src</code> (BREAKING)</li>
</ul>
<h2 id="v121">v1.2.1</h2>
@ -186,12 +186,12 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v1.1.0...v1.2.0">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow disabling colors via <code class="highlighter-rouge">NO_COLOR</code> environment variable</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Enable <code class="highlighter-rouge">errexit</code>, <code class="highlighter-rouge">nounset</code> and <code class="highlighter-rouge">pipefail</code> options at the top of the script already</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Allow disabling colors via <code class="language-plaintext highlighter-rouge">NO_COLOR</code> environment variable</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Enable <code class="language-plaintext highlighter-rouge">errexit</code>, <code class="language-plaintext highlighter-rouge">nounset</code> and <code class="language-plaintext highlighter-rouge">pipefail</code> options at the top of the script already</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />More refined colors (thanks @arathai)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add a changelog to the README</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="highlighter-rouge">__os</code> magic var (limited to discovering OSX and defaulting to Linux for now)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="highlighter-rouge">__base</code> magic var (<code class="highlighter-rouge">main</code>, if the source script is <code class="highlighter-rouge">main.sh</code>)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="language-plaintext highlighter-rouge">__os</code> magic var (limited to discovering OSX and defaulting to Linux for now)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="language-plaintext highlighter-rouge">__base</code> magic var (<code class="language-plaintext highlighter-rouge">main</code>, if the source script is <code class="language-plaintext highlighter-rouge">main.sh</code>)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Enable long, GNU style options (thanks @zbeekman)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add Travis CI automated testing for Linux</li>
</ul>
@ -202,9 +202,9 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/v1.0.3...v1.1.0">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="highlighter-rouge">ALLOW_REMAINDERS</code> configuration to templater</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="language-plaintext highlighter-rouge">ALLOW_REMAINDERS</code> configuration to templater</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Fix typo: debugmdoe to debugmode (thanks @jokajak)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Use <code class="highlighter-rouge">${BASH_SOURCE[0]}</code> for <code class="highlighter-rouge">__file</code> instead of <code class="highlighter-rouge">${0}</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Use <code class="language-plaintext highlighter-rouge">${BASH_SOURCE[0]}</code> for <code class="language-plaintext highlighter-rouge">__file</code> instead of <code class="language-plaintext highlighter-rouge">${0}</code></li>
</ul>
<h2 id="v103">v1.0.3</h2>
@ -213,8 +213,8 @@
<a href="https://github.com/kvz/bash3boilerplate/compare/5db569125319a89b9561b434db84e4d91faefb63...v1.0.3">Diff</a>.</p>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="highlighter-rouge">ini_val</code>, <code class="highlighter-rouge">megamount</code>, <code class="highlighter-rouge">parse_url</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add re-usable libraries in <code class="highlighter-rouge">./src</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add <code class="language-plaintext highlighter-rouge">ini_val</code>, <code class="language-plaintext highlighter-rouge">megamount</code>, <code class="language-plaintext highlighter-rouge">parse_url</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Add re-usable libraries in <code class="language-plaintext highlighter-rouge">./src</code></li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Use npm as an additional distribution channel</li>
</ul>
@ -239,7 +239,7 @@
</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="/assets/build/app.a6d50511e193d4224561.js"></script>
<script src="/assets/build/app.5c7edb9a417afd6fed50.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),

View File

@ -10,7 +10,7 @@
<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="/assets/build/app.a6d50511e193d4224561.css" media="screen" charset="utf-8">
<link href="/assets/build/app.651a09ef8a9b4bbd05bb.css" rel="stylesheet">
</head>
<body>
<header>
@ -41,14 +41,14 @@
<p>You can incorporate BASH3 Boilerplate into your project in one of two ways:</p>
<ol>
<li>Copy the desired portions of <a href="http://bash3boilerplate.sh/main.sh"><code class="highlighter-rouge">main.sh</code></a> into your own script.</li>
<li>Download <a href="http://bash3boilerplate.sh/main.sh"><code class="highlighter-rouge">main.sh</code></a> and start pressing the delete-key to remove unwanted things</li>
<li>Copy the desired portions of <a href="http://bash3boilerplate.sh/main.sh"><code class="language-plaintext highlighter-rouge">main.sh</code></a> into your own script.</li>
<li>Download <a href="http://bash3boilerplate.sh/main.sh"><code class="language-plaintext highlighter-rouge">main.sh</code></a> and start pressing the delete-key to remove unwanted things</li>
</ol>
<p>Once the <code class="highlighter-rouge">main.sh</code> has been tailor-made for your project, you can either append your own script in the same file, or source it in the following ways:</p>
<p>Once the <code class="language-plaintext highlighter-rouge">main.sh</code> has been tailor-made for your project, you can either append your own script in the same file, or source it in the following ways:</p>
<ol>
<li>Copy <a href="http://bash3boilerplate.sh/main.sh"><code class="highlighter-rouge">main.sh</code></a> into the same directory as your script and then edit and embed it into your script using Bashs <code class="highlighter-rouge">source</code> include feature, e.g.:</li>
<li>Copy <a href="http://bash3boilerplate.sh/main.sh"><code class="language-plaintext highlighter-rouge">main.sh</code></a> into the same directory as your script and then edit and embed it into your script using Bashs <code class="language-plaintext highlighter-rouge">source</code> include feature, e.g.:</li>
</ol>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/env bash</span>
@ -56,7 +56,7 @@
</code></pre></div></div>
<ol>
<li>Source <a href="http://bash3boilerplate.sh/main.sh"><code class="highlighter-rouge">main.sh</code></a> in your script or at the command line:</li>
<li>Source <a href="http://bash3boilerplate.sh/main.sh"><code class="language-plaintext highlighter-rouge">main.sh</code></a> in your script or at the command line:</li>
</ol>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/env bash</span>
@ -66,16 +66,16 @@
<h2 id="how-do-i-add-a-command-line-flag">How do I add a command-line flag?</h2>
<ol>
<li>Copy the line from the <code class="highlighter-rouge">main.sh</code> <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L109-L115">read block</a> that most resembles the desired behavior and paste the line into the same block.</li>
<li>Edit the single-character (e.g., <code class="highlighter-rouge">-d</code>) and, if present, the multi-character (e.g., <code class="highlighter-rouge">--debug</code>) versions of the flag in the copied line.</li>
<li>Omit the <code class="highlighter-rouge">[arg]</code> text in the copied line, if the desired flag takes no arguments.</li>
<li>Omit or edit the text after <code class="highlighter-rouge">Default=</code> to set or not set default values, respectively.</li>
<li>Omit the <code class="highlighter-rouge">Required.</code> text, if the flag is optional.</li>
<li>Copy the line from the <code class="language-plaintext highlighter-rouge">main.sh</code> <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L109-L115">read block</a> that most resembles the desired behavior and paste the line into the same block.</li>
<li>Edit the single-character (e.g., <code class="language-plaintext highlighter-rouge">-d</code>) and, if present, the multi-character (e.g., <code class="language-plaintext highlighter-rouge">--debug</code>) versions of the flag in the copied line.</li>
<li>Omit the <code class="language-plaintext highlighter-rouge">[arg]</code> text in the copied line, if the desired flag takes no arguments.</li>
<li>Omit or edit the text after <code class="language-plaintext highlighter-rouge">Default=</code> to set or not set default values, respectively.</li>
<li>Omit the <code class="language-plaintext highlighter-rouge">Required.</code> text, if the flag is optional.</li>
</ol>
<h2 id="how-do-i-access-the-value-of-a-command-line-argument">How do I access the value of a command-line argument?</h2>
<p>To find out the value of an argument, append the corresponding single-character flag to the text <code class="highlighter-rouge">$arg_</code>. For example, if the [read block]
<p>To find out the value of an argument, append the corresponding single-character flag to the text <code class="language-plaintext highlighter-rouge">$arg_</code>. For example, if the [read block]
contains the line</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="nt">-t</span> <span class="nt">--temp</span> <span class="o">[</span>arg] Location of tempfile. <span class="nv">Default</span><span class="o">=</span><span class="s2">"/tmp/bar"</span>
@ -88,7 +88,7 @@ contains the line</p>
<h2 id="what-is-a-magic-variable">What is a magic variable?</h2>
<p>The <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L26-L28">magic variables</a> in <code class="highlighter-rouge">main.sh</code> are special in that they have a different value, depending on your environment. You can use <code class="highlighter-rouge">${__file}</code> to get a reference to your current script, and <code class="highlighter-rouge">${__dir}</code> to get a reference to the directory it lives in. This is not to be confused with the location of the calling script that might be sourcing the <code class="highlighter-rouge">${__file}</code>, which is accessible via <code class="highlighter-rouge">${0}</code>, or the current directory of the administrator running the script, accessible via <code class="highlighter-rouge">$(pwd)</code>.</p>
<p>The <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L26-L28">magic variables</a> in <code class="language-plaintext highlighter-rouge">main.sh</code> are special in that they have a different value, depending on your environment. You can use <code class="language-plaintext highlighter-rouge">${__file}</code> to get a reference to your current script, and <code class="language-plaintext highlighter-rouge">${__dir}</code> to get a reference to the directory it lives in. This is not to be confused with the location of the calling script that might be sourcing the <code class="language-plaintext highlighter-rouge">${__file}</code>, which is accessible via <code class="language-plaintext highlighter-rouge">${0}</code>, or the current directory of the administrator running the script, accessible via <code class="language-plaintext highlighter-rouge">$(pwd)</code>.</p>
<h2 id="how-do-i-submit-an-issue-report">How do I submit an issue report?</h2>
@ -120,17 +120,17 @@ Somewhat inconsistent but true to Unix ancestry the abbreviation for our
<p>The source mainly consists of:</p>
<ul>
<li><code class="highlighter-rouge">./README.md</code> (Front page)</li>
<li><code class="highlighter-rouge">./FAQ.md</code> (FAQ page)</li>
<li><code class="highlighter-rouge">./CHANGELOG.md</code> (changelog page)</li>
<li><code class="highlighter-rouge">./website/_layouts/default.html</code> (the design in which all pages are rendered)</li>
<li><code class="highlighter-rouge">./website/assets/app.js</code> (main JS file)</li>
<li><code class="highlighter-rouge">./website/assets/style.css</code> (main CSS file)</li>
<li><code class="language-plaintext highlighter-rouge">./README.md</code> (Front page)</li>
<li><code class="language-plaintext highlighter-rouge">./FAQ.md</code> (FAQ page)</li>
<li><code class="language-plaintext highlighter-rouge">./CHANGELOG.md</code> (changelog page)</li>
<li><code class="language-plaintext highlighter-rouge">./website/_layouts/default.html</code> (the design in which all pages are rendered)</li>
<li><code class="language-plaintext highlighter-rouge">./website/assets/app.js</code> (main JS file)</li>
<li><code class="language-plaintext highlighter-rouge">./website/assets/style.css</code> (main CSS file)</li>
</ul>
<p>The rest is dark magic from which you should probably steer clear. : )</p>
<p>Any changes should be proposed as PRs. Anything added to <code class="highlighter-rouge">master</code> is automatically deployed using a combination of Travis CI and GitHub Pages.</p>
<p>Any changes should be proposed as PRs. Anything added to <code class="language-plaintext highlighter-rouge">master</code> is automatically deployed using a combination of Travis CI and GitHub Pages.</p>
<h2 id="you-are-saying-you-are-portable-but-why-wont-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?</h2>
@ -140,8 +140,8 @@ offer at least version 3 of it. Make sure you have that available and b3bp will
<p>We run automated tests to make sure that it will. Here is some proof for the following platforms:</p>
<ul>
<li><a href="https://travis-ci.org/kvz/bash3boilerplate/jobs/109804166#L91-L94">Linux</a> <code class="highlighter-rouge">GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)</code></li>
<li><a href="https://travis-ci.org/kvz/bash3boilerplate/jobs/109804167#L2453-L2455">OSX</a> <code class="highlighter-rouge">GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)</code></li>
<li><a href="https://travis-ci.org/kvz/bash3boilerplate/jobs/109804166#L91-L94">Linux</a> <code class="language-plaintext highlighter-rouge">GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)</code></li>
<li><a href="https://travis-ci.org/kvz/bash3boilerplate/jobs/109804167#L2453-L2455">OSX</a> <code class="language-plaintext highlighter-rouge">GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)</code></li>
</ul>
<p>This portability, however, does not mean that we try to be compatible with
@ -150,11 +150,11 @@ you pasted it in anything but Bash 3 and up.</p>
<h2 id="how-do-i-do-operating-system-detection">How do I do Operating System detection?</h2>
<p>We used to offer a magic <code class="highlighter-rouge">__os</code> variable, but we quickly <a href="https://github.com/kvz/bash3boilerplate/issues/38">discovered</a> that it would be hard
<p>We used to offer a magic <code class="language-plaintext highlighter-rouge">__os</code> variable, but we quickly <a href="https://github.com/kvz/bash3boilerplate/issues/38">discovered</a> that it would be hard
to create a satisfactory abstraction that is not only correct, but also covers enough use-cases,
while still having a relatively small footprint in <code class="highlighter-rouge">main.sh</code>.</p>
while still having a relatively small footprint in <code class="language-plaintext highlighter-rouge">main.sh</code>.</p>
<p>For simple OS detection, we recommend using the <code class="highlighter-rouge">${OSTYPE}</code> variable available in Bash as
<p>For simple OS detection, we recommend using the <code class="language-plaintext highlighter-rouge">${OSTYPE}</code> variable available in Bash as
is demoed in <a href="http://stackoverflow.com/a/8597411/151666">this stackoverflow post</a>:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[[</span> <span class="s2">"</span><span class="k">${</span><span class="nv">OSTYPE</span><span class="k">}</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"linux-gnu"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
@ -176,7 +176,7 @@ is demoed in <a href="http://stackoverflow.com/a/8597411/151666">this stackoverf
<h2 id="how-do-i-access-a-potentially-unset-environment-variable">How do I access a potentially unset (environment) variable?</h2>
<p>The set -o nounset line in <code class="highlighter-rouge">main.sh</code> causes error termination when an unset environment variables is detected as unbound. There are multiple ways to avoid this.</p>
<p>The set -o nounset line in <code class="language-plaintext highlighter-rouge">main.sh</code> causes error termination when an unset environment variables is detected as unbound. There are multiple ways to avoid this.</p>
<p>Some code to illustrate:</p>
@ -188,7 +188,7 @@ is demoed in <a href="http://stackoverflow.com/a/8597411/151666">this stackoverf
<span class="nv">NAME3</span><span class="o">=</span><span class="k">${</span><span class="nv">NAME3</span><span class="k">:-</span><span class="nv">Damian</span><span class="k">}</span><span class="p">;</span> <span class="nb">echo</span> <span class="k">${</span><span class="nv">NAME3</span><span class="k">}</span> <span class="c"># echos Damian, $NAME3 is set to Damian</span>
</code></pre></div></div>
<p>This subject is briefly touched on as well in the <a href="README.md#safety-and-portability">Safety and Portability section under point 5</a>. b3bp currently uses <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L252">method 1</a> when we want to access a variable that could be undeclared, and <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L31">method 3</a> when we also want to set a default to an undeclared variable, because we feel it is more readable than method 2. We feel <code class="highlighter-rouge">:=</code> is easily overlooked, and not very beginner friendly. Method 3 seems more explicit in that regard in our humble opinion.</p>
<p>This subject is briefly touched on as well in the <a href="README.md#safety-and-portability">Safety and Portability section under point 5</a>. b3bp currently uses <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L252">method 1</a> when we want to access a variable that could be undeclared, and <a href="https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L31">method 3</a> when we also want to set a default to an undeclared variable, because we feel it is more readable than method 2. We feel <code class="language-plaintext highlighter-rouge">:=</code> is easily overlooked, and not very beginner friendly. Method 3 seems more explicit in that regard in our humble opinion.</p>
<h2 id="how-can-i-detect-or-trap-ctrl-c-and-other-signals">How can I detect or trap Ctrl-C and other signals?</h2>
@ -206,7 +206,7 @@ is demoed in <a href="http://stackoverflow.com/a/8597411/151666">this stackoverf
<h2 id="how-can-i-get-the-pid-of-my-running-script">How can I get the PID of my running script?</h2>
<p>The PID of a running script is contained in the <code class="highlighter-rouge">${$}</code> variable. This is <em>not</em> the pid of any subshells. With Bash 4 you can get the PID of your subshell with <code class="highlighter-rouge">${BASHPID}</code>. For a comprehensive list of Bash built in variables see, e.g., http://www.tldp.org/LDP/abs/html/internalvariables.html</p>
<p>The PID of a running script is contained in the <code class="language-plaintext highlighter-rouge">${$}</code> variable. This is <em>not</em> the pid of any subshells. With Bash 4 you can get the PID of your subshell with <code class="language-plaintext highlighter-rouge">${BASHPID}</code>. For a comprehensive list of Bash built in variables see, e.g., http://www.tldp.org/LDP/abs/html/internalvariables.html</p>
<p><a href="/">« Home</a></p>
@ -229,7 +229,7 @@ is demoed in <a href="http://stackoverflow.com/a/8597411/151666">this stackoverf
</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="/assets/build/app.a6d50511e193d4224561.js"></script>
<script src="/assets/build/app.5c7edb9a417afd6fed50.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),

View File

@ -10,7 +10,7 @@
<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="/assets/build/app.a6d50511e193d4224561.css" media="screen" charset="utf-8">
<link href="/assets/build/app.651a09ef8a9b4bbd05bb.css" rel="stylesheet">
</head>
<body>
<header>
@ -50,7 +50,7 @@ they are reusable as-is in most scripts.</p>
<h2 id="goals">Goals</h2>
<p>Delete-Key-<strong>Friendly</strong>. Instead of introducing packages, includes, compilers, etc., we propose using <a href="http://bash3boilerplate.sh/main.sh"><code class="highlighter-rouge">main.sh</code></a> as a base and removing the parts you dont need.
<p>Delete-Key-<strong>Friendly</strong>. Instead of introducing packages, includes, compilers, etc., we propose using <a href="http://bash3boilerplate.sh/main.sh"><code class="language-plaintext highlighter-rouge">main.sh</code></a> as a base and removing the parts you dont need.
While this may feel a bit archaic at first, it is exactly the strength of Bash scripts that we should want to embrace.</p>
<p><strong>Portable</strong>. We are targeting Bash 3 (OSX still ships
@ -65,7 +65,7 @@ dependency.</p>
<li>Safe by default (break on error, pipefail, etc.)</li>
<li>Configuration by environment variables</li>
<li>Simple command-line argument parsing that requires no external dependencies. Definitions are parsed from help info, ensuring there will be no duplication</li>
<li>Helpful magic variables like <code class="highlighter-rouge">__file</code> and <code class="highlighter-rouge">__dir</code></li>
<li>Helpful magic variables like <code class="language-plaintext highlighter-rouge">__file</code> and <code class="language-plaintext highlighter-rouge">__dir</code></li>
<li>Logging that supports colors and is compatible with <a href="http://en.wikipedia.org/wiki/Syslog#Severity_levels">Syslog Severity levels</a>, as well as the <a href="http://12factor.net/">twelve-factor</a> guidelines</li>
</ul>
@ -83,14 +83,14 @@ vim main.sh
<h3 id="option-2-clone-the-entire-project">Option 2: Clone the entire project</h3>
<p>Besides <code class="highlighter-rouge">main.sh</code>, this will also get you the entire b3bp repository. This includes a few extra functions that we keep in the <code class="highlighter-rouge">./src</code> directory.</p>
<p>Besides <code class="language-plaintext highlighter-rouge">main.sh</code>, this will also get you the entire b3bp repository. This includes a few extra functions that we keep in the <code class="language-plaintext highlighter-rouge">./src</code> directory.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone git@github.com:kvz/bash3boilerplate.git
</code></pre></div></div>
<h3 id="option-3-require-via-npm">Option 3: Require via npm</h3>
<p>As of <code class="highlighter-rouge">v1.0.3</code>, b3bp can also be installed as a Node module, meaning you can define it as a dependency in <code class="highlighter-rouge">package.json</code> via:</p>
<p>As of <code class="language-plaintext highlighter-rouge">v1.0.3</code>, b3bp can also be installed as a Node module, meaning you can define it as a dependency in <code class="language-plaintext highlighter-rouge">package.json</code> via:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm init
npm <span class="nb">install</span> <span class="nt">--save</span> <span class="nt">--save-exact</span> bash3boilerplate
@ -108,7 +108,7 @@ npm <span class="nb">install</span> <span class="nt">--save</span> <span class="
<h2 id="best-practices">Best practices</h2>
<p>As of <code class="highlighter-rouge">v1.0.3</code>, b3bp offers some nice re-usable libraries in <code class="highlighter-rouge">./src</code>. In order to make the snippets in <code class="highlighter-rouge">./src</code> more useful, we recommend the following guidelines.</p>
<p>As of <code class="language-plaintext highlighter-rouge">v1.0.3</code>, b3bp offers some nice re-usable libraries in <code class="language-plaintext highlighter-rouge">./src</code>. In order to make the snippets in <code class="language-plaintext highlighter-rouge">./src</code> more useful, we recommend the following guidelines.</p>
<h3 id="function-packaging">Function packaging</h3>
@ -121,7 +121,7 @@ npm <span class="nb">install</span> <span class="nt">--save</span> <span class="
</span><span class="nb">export</span> <span class="nt">-f</span> my_script
</code></pre></div></div>
<p>This allows a user to <code class="highlighter-rouge">source</code> your script or invoke it as a script.</p>
<p>This allows a user to <code class="language-plaintext highlighter-rouge">source</code> your script or invoke it as a script.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Running as a script</span>
<span class="nv">$ </span>./my_script.sh some args <span class="nt">--blah</span>
@ -135,9 +135,9 @@ npm <span class="nb">install</span> <span class="nt">--save</span> <span class="
<h3 id="scoping">Scoping</h3>
<ol>
<li>In functions, use <code class="highlighter-rouge">local</code> before every variable declaration.</li>
<li>Use <code class="highlighter-rouge">UPPERCASE_VARS</code> to indicate environment variables that can be controlled outside your script.</li>
<li>Use <code class="highlighter-rouge">__double_underscore_prefixed_vars</code> to indicate global variables that are solely controlled inside your script, with the exception of arguments that are already prefixed with <code class="highlighter-rouge">arg_</code>, as well as functions, over which b3bp poses no restrictions.</li>
<li>In functions, use <code class="language-plaintext highlighter-rouge">local</code> before every variable declaration.</li>
<li>Use <code class="language-plaintext highlighter-rouge">UPPERCASE_VARS</code> to indicate environment variables that can be controlled outside your script.</li>
<li>Use <code class="language-plaintext highlighter-rouge">__double_underscore_prefixed_vars</code> to indicate global variables that are solely controlled inside your script, with the exception of arguments that are already prefixed with <code class="language-plaintext highlighter-rouge">arg_</code>, as well as functions, over which b3bp poses no restrictions.</li>
</ol>
<h3 id="coding-style">Coding style</h3>
@ -145,19 +145,19 @@ npm <span class="nb">install</span> <span class="nt">--save</span> <span class="
<ol>
<li>Use two spaces for tabs, do not use tab characters.</li>
<li>Do not introduce whitespace at the end of lines or on blank lines as they obfuscate version control diffs.</li>
<li>Use long options (<code class="highlighter-rouge">logger --priority</code> vs <code class="highlighter-rouge">logger -p</code>). If you are on the CLI, abbreviations make sense for efficiency. Nevertheless, when you are writing reusable scripts, a few extra keystrokes will pay off in readability and avoid ventures into man pages in the future, either by you or your collaborators. Similarly, we prefer <code class="highlighter-rouge">set -o nounset</code> over <code class="highlighter-rouge">set -u</code>.</li>
<li>Use a single equal sign when checking <code class="highlighter-rouge">if [[ "${NAME}" = "Kevin" ]]</code>; double or triple signs are not needed.</li>
<li>Use the new bash builtin test operator (<code class="highlighter-rouge">[[ ... ]]</code>) rather than the old single square bracket test operator or explicit call to <code class="highlighter-rouge">test</code>.</li>
<li>Use long options (<code class="language-plaintext highlighter-rouge">logger --priority</code> vs <code class="language-plaintext highlighter-rouge">logger -p</code>). If you are on the CLI, abbreviations make sense for efficiency. Nevertheless, when you are writing reusable scripts, a few extra keystrokes will pay off in readability and avoid ventures into man pages in the future, either by you or your collaborators. Similarly, we prefer <code class="language-plaintext highlighter-rouge">set -o nounset</code> over <code class="language-plaintext highlighter-rouge">set -u</code>.</li>
<li>Use a single equal sign when checking <code class="language-plaintext highlighter-rouge">if [[ "${NAME}" = "Kevin" ]]</code>; double or triple signs are not needed.</li>
<li>Use the new bash builtin test operator (<code class="language-plaintext highlighter-rouge">[[ ... ]]</code>) rather than the old single square bracket test operator or explicit call to <code class="language-plaintext highlighter-rouge">test</code>.</li>
</ol>
<h3 id="safety-and-portability">Safety and Portability</h3>
<ol>
<li>Use <code class="highlighter-rouge">{}</code> to enclose your variables. Otherwise, Bash will try to access the <code class="highlighter-rouge">$ENVIRONMENT_app</code> variable in <code class="highlighter-rouge">/srv/$ENVIRONMENT_app</code>, whereas you probably intended <code class="highlighter-rouge">/srv/${ENVIRONMENT}_app</code>. Since it is easy to miss cases like this, we recommend that you make enclosing a habit.</li>
<li>Use <code class="highlighter-rouge">set</code>, rather than relying on a shebang like <code class="highlighter-rouge"><span class="c">#!/usr/bin/env bash -e</span></code>, since that is neutralized when someone runs your script as <code class="highlighter-rouge">bash yourscript.sh</code>.</li>
<li>Use <code class="highlighter-rouge"><span class="c">#!/usr/bin/env bash</span></code>, as it is more portable than <code class="highlighter-rouge"><span class="c">#!/bin/bash</span></code>.</li>
<li>Use <code class="highlighter-rouge">${BASH_SOURCE[0]}</code> if you refer to current file, even if it is sourced by a parent script. In other cases, use <code class="highlighter-rouge">${0}</code>.</li>
<li>Use <code class="highlighter-rouge">:-</code> if you want to test variables that could be undeclared. For instance, with <code class="highlighter-rouge">if [[ "${NAME:-}" = "Kevin" ]]</code>, <code class="highlighter-rouge">$NAME</code> will evaluate to <code class="highlighter-rouge">Kevin</code> if the variable is empty. The variable itself will remain unchanged. The syntax to assign a default value is <code class="highlighter-rouge">${NAME:=Kevin}</code>.</li>
<li>Use <code class="language-plaintext highlighter-rouge">{}</code> to enclose your variables. Otherwise, Bash will try to access the <code class="language-plaintext highlighter-rouge">$ENVIRONMENT_app</code> variable in <code class="language-plaintext highlighter-rouge">/srv/$ENVIRONMENT_app</code>, whereas you probably intended <code class="language-plaintext highlighter-rouge">/srv/${ENVIRONMENT}_app</code>. Since it is easy to miss cases like this, we recommend that you make enclosing a habit.</li>
<li>Use <code class="language-plaintext highlighter-rouge">set</code>, rather than relying on a shebang like <code class="language-plaintext highlighter-rouge">#!/usr/bin/env bash -e</code>, since that is neutralized when someone runs your script as <code class="language-plaintext highlighter-rouge">bash yourscript.sh</code>.</li>
<li>Use <code class="language-plaintext highlighter-rouge">#!/usr/bin/env bash</code>, as it is more portable than <code class="language-plaintext highlighter-rouge">#!/bin/bash</code>.</li>
<li>Use <code class="language-plaintext highlighter-rouge">${BASH_SOURCE[0]}</code> if you refer to current file, even if it is sourced by a parent script. In other cases, use <code class="language-plaintext highlighter-rouge">${0}</code>.</li>
<li>Use <code class="language-plaintext highlighter-rouge">:-</code> if you want to test variables that could be undeclared. For instance, with <code class="language-plaintext highlighter-rouge">if [[ "${NAME:-}" = "Kevin" ]]</code>, <code class="language-plaintext highlighter-rouge">$NAME</code> will evaluate to <code class="language-plaintext highlighter-rouge">Kevin</code> if the variable is empty. The variable itself will remain unchanged. The syntax to assign a default value is <code class="language-plaintext highlighter-rouge">${NAME:=Kevin}</code>.</li>
</ol>
<h2 id="who-uses-b3bp">Who uses b3bp?</h2>
@ -235,7 +235,7 @@ as you leave these references intact in the header comments of your source files
</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="/assets/build/app.a6d50511e193d4224561.js"></script>
<script src="/assets/build/app.5c7edb9a417afd6fed50.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),

View File

@ -280,6 +280,7 @@ if [[ "${__b3bp_tmp_opts:-}" ]]; 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