mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2024-12-18 22:27:51 +00:00
Move intro to blog
This commit is contained in:
parent
6aadcb3222
commit
bd844228f9
76
README.md
76
README.md
@ -10,74 +10,26 @@ Here's an attempt to bundle those things in a generalized way so that
|
||||
they are reusable as-is in most of my (and hopefully your, if not ping
|
||||
me) programs.
|
||||
|
||||
## Goals
|
||||
An up to date [intro is found on my blog](http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/).
|
||||
|
||||
I'm going to be pragmatic and violate good practices like DRY
|
||||
and the things I know about sourcing files, git submodules,
|
||||
package management, etc.
|
||||
## Contributing
|
||||
|
||||
I feel that when a program consists of multiple files, BASH
|
||||
may very well not be the right tool for the job.
|
||||
Feel free to fork this project. We will happily merge bug fixes or other small
|
||||
improvements. For bigger changes you should probably get in touch with us
|
||||
before you start to avoid not seeing them merged.
|
||||
|
||||
Copy-pasting, and removing what you don't need may not seem
|
||||
very rocket-scientific, or 2013, but in fact neither is BASH.
|
||||
## Versioning
|
||||
|
||||
Keeping things simple, small and lightweight should be key
|
||||
here.
|
||||
Discourse implements the Semantic Versioning guidelines.
|
||||
|
||||
Aiming for portability I'm targetting BASH 3 (OSX still ships
|
||||
with v3 for instance). If you're going to ask people to install
|
||||
BASH 4 first, you might as well pick a better language as a
|
||||
dependency and code up your script in that.
|
||||
Releases will be numbered with the following format:
|
||||
|
||||
The main template shoud only have features that are needed
|
||||
80% of the time you write BASH.
|
||||
`<major>.<minor>.<patch>`
|
||||
|
||||
Other cool functions can be adopted into this repository,
|
||||
but should not be referenced by the `main.sh` template and function
|
||||
purely as a resource.
|
||||
And constructed with the following guidelines:
|
||||
|
||||
## Features
|
||||
|
||||
- Structure
|
||||
- Configuration by environment variables
|
||||
- Configuration by commandline arguments (definitions parsed from help info,
|
||||
so no duplication needed)
|
||||
- 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)
|
||||
|
||||
## Conventions
|
||||
|
||||
It's the task of the script's **caller** to:
|
||||
- Redirect the output to appropriate locations
|
||||
- Correctly set the PATH variable (think [cronjobs](http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/))
|
||||
|
||||
## Recommendations
|
||||
|
||||
- Use spaces vs tabs so you can copy-paste parts directly into
|
||||
the console, without BASH's automcomplete firing on every tab
|
||||
character
|
||||
- Use `set -eu`, so it will break on every error
|
||||
and undefined variable. if you're expecting an error, add `||true`
|
||||
to your command.
|
||||
Using `set -eu` over the interpreter `#!/bin/bash -eu` makes
|
||||
sure the flags are respected even when your script is called like `bash main.sh`.
|
||||
- Checkout [The 10 Commandments of Logging](http://www.masterzen.fr/2013/01/13/the-10-commandments-of-logging/)
|
||||
|
||||
## Notes
|
||||
|
||||
- Use `emergency` to exit with 1
|
||||
|
||||
## Compile
|
||||
|
||||
For those who want the template to get out of there way, I'm also
|
||||
shipping a compiled version that removes some comments, puts
|
||||
more things on one line, etc. For readability and boilerplate development, use the
|
||||
bigger version.
|
||||
|
||||
## Fork
|
||||
|
||||
I'm looking forward to your comments and pull requests!
|
||||
|
||||
On [github](http://github.com/kvz/bash3boilerplate)
|
||||
* Breaking backward compatibility bumps the major (and resets the minor and patch)
|
||||
* New additions without breaking backward compatibility bumps the minor (and resets the patch)
|
||||
* Bug fixes and misc changes bumps the patch
|
||||
|
||||
For more information on SemVer, please visit http://semver.org/.
|
||||
|
Loading…
Reference in New Issue
Block a user