Outputs Front-Mater formatted failures for Bash functions not returning 0 exit status.
See the
exampleGitbranchfor usage examples.
Bash version ~4.3 or greater and the following command line utilities;
-
printffor returning values between functions -
localwith-nand-aoptions available for passing references to variables between functions and assigning local arrays -
setis utilizingset -E -o functraceor similar prior to setting failuretrap
See
info printffor documentation andhelp local/help setfor more information on additional options.
Add one of the available clone URLs to a current project...
cd your-project
_url='https://github.com/bash-utilities/trap-failure.git'
_dir='modules/trap-failure'
git submodule add -b master "${_url}" "${_dir}"Older versions of
gitmay require the following to populate${_dir}...
git submodule update --init --recursiveCheck that something similar to the following results from git status...
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitmodules
new file: modules/trap-failure
... commit and push these changes then notify anyone contributing to your project that...
git submodule update --init --recursive
git submodule update --merge... commands may be useful for updating.
Tip, those that make a fresh
cloneof your project may use...
git clone --recurse-submodules <your-repositorys-url>... to set-up all the various submodules that your project utilizes.
Note, if at any point in the future
git submodule foreach git statusreports a detachedHEAD, and that is somehow bothersome then try...
cd modules/trap-failure
git checkout master
git pull... to re-attach the submodule's
HEADonce again.
Bash Trap Failure documentation on a submodule for Git tracked Bash scripts
Copyright (C) 2019 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.