Framework for writing modular, discoverable, testable Bash scripts
This is a minor update to add a few test helpers, _GO_PLATFORM
variables and the ./go goinfo
command, several file system processing modules, and a handful of project improvements.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
All of the issues and pull requests for this release are visible in the v1.7.0 milestone.
./go null
The ./go null
command verifies that the framework is installed and functioning properly (#190).
There are a few powerful new test helper functions:
create_forwarding_script
(#192, #195): Used to create a wrapper in BATS_TEST_BINDIR
to make a system program accessible while restricting PATH
via PATH="$BATS_TEST_BINDIR"
.restore_programs_in_path
(#196): Allows a single call to remove multiple command stub scripts.run_test_script
(#196): Creates and runs a test script in one step, so that create_bats_test_script and run need not be called separately.run_bats_test_suite
(#196): A specialized version of run_test_script
specifically for generating and running Bats test cases.run_bats_test_suite_in_isolation
(#196): An even more specialized version of run_bats_test_suite
to ensure that PATH
is restricted to BATS_TEST_BINDIR
and the Bats libexec/
directory within the suite.lib/bats/background-process
(#197): Helpers for managing and validating background processes.skip_if_none_present_on_system
(#198): Skips a test if none of the specified system programs are available._GO_PLATFORM
vars and ./go goinfo
commandThe lib/platform
module introduced in #200 provides an interface to detect on which system the script is running. Is parses /etc/os-release if it's available; otherwise uses OSTYPE
, uname -r
, and sw_vers -productVersion
(on macOS).
The ./go goinfo
command introduced in #216 uses the lib/platform
module to print version information about the go-script-bash framework, Bash, and the host operating system:
$ ./go goinfo
_GO_CORE_VERSION: v1.7.0
BASH_VERSION: 4.4.12(1)-release
OSTYPE: darwin16.3.0
_GO_PLATFORM_ID: macos
_GO_PLATFORM_VERSION_ID: 10.13
Introduced in #201, @go.native_file_path_or_url
from lib/portability
converts a file system path or file://
URL to a platform-native path. This is necessitated by MSYS2, especially Git for Windows, which has system programs which expect Windows-native paths as input, or whose output will reflect Windows-native paths. It's used in several tests, as well as the ./go get
command.
The lib/path
module introduced in #203 and #206 includes functions to canonicalize file system paths, resolve symlinks, and walk directories.
lib/fileutil
from #204 and updated in #207 and #210 contains functions to safely create directories (with extensive error reporting), to collect all the regular files within a directory structure, to safely copy all files into a new directory structure, and to safely mirror directories using tar
.
lib/diff
from #205 contains functions to log or edit differences between files and directory trees.
lib/archive
from #211 contains the @go.create_gzipped_tarball
convenience function to easily and safely create .tar.gz
archive files.
The project now contains a GitHub issue and pull request templates, a GitHub CODEOWNERS
file, and an Appveyor build to ensure Windows compatibility. See:
stub_program_in_path
(#194): Now ensures that new stubs are passed to hash
. Previously, if a command had already been invoked, Bash would remember its path, and ignore the new stub.You can see the details of every change by issuing one or more of the following commands after cloning: https://github.com/mbland/go-script-bash
$ ./go changes v1.6.0 v1.7.0 $ gitk v1.6.0..v1.7.0
This is a minor update to add the capability to go-template
to download a release tarball from GitHub rather than using git clone
to add the go-script-bash framework to a project working directory.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
All of the issues and pull requests for this release are visible in the v1.6.0 milestone.
go-template
Thanks to Juan Saavedra, go-template
now has the capability to download and unpack a release tarbal from GitHub in order to add the go-script-bash framework to a project's working directory, rather than relying on git clone
. Now git clone
will be used as a backup in case the system doesn't have the tools to download and unpack the tarball, or the operation fails for some reason.
None in this release.
You can see the details of every change by issuing one or more of the following commands after cloning: https://github.com/mbland/go-script-bash
$ ./go changes v1.5.0 v1.6.0 $ gitk v1.5.0..HEAD
This is a minor update to add the lib/prompt
and lib/existence
modules that import functionality from the first draft of the mbland/certbot-webroot-setup project.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
All of the issues and pull requests for this release are visible in the v1.5.0 milestone.
lib/prompt
moduleThe new lib/prompt
module contains several new user input prompt functions. Also, @go.select_option
has been moved from go-core.bash
to the lib/prompt
module. The new ./go demo-core prompt
command demonstrates most of the new user prompt behavior.
lib/existence
moduleThe new lib/existence
module contains convenience functions for checking whether a file or command exists and is accessible on the system, and provides standard error reporting if not.
@go.trim
added to lib/strings
@go.trim
trims leading and trailing whitespace from strings, and supports the parsing of user input data in functions from the lib/prompt
module.
Just one this time: ./go new --test
now outputs load environment
correctly for top-level tests within _GO_TEST_DIR
(#171, #172).
You can see the details of every change by issuing one or more of the following commands after cloning: https://github.com/mbland/go-script-bash
$ ./go changes v1.4.0 v1.5.0 $ gitk v1.4.0..HEAD
This release contains some major improvements, including an O(5.3-18x) Bats test performance improvement, the new lib/bats-main
and other testing library updates, the go-template
bootstrap script, _GO_STANDALONE
mode, improved _GO_USE_MODULES
semantics, the new get
and new
commands, npm-like plugin semantics, and more.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
All of the issues and pull requests for this release are visible in the v1.4.0 milestone.
Insight into how Bats captures stack trace information led to several rounds of performance optimizations to remove subshells and other child processes that resulted in a massive improvement. All the times below were measured on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM.
The first round of improvements, to the go-script-bash framework itself, took the existing test suite running under Bash 3.2.57(1)-release from macOS 10.12 from O(7-8m) down to O(3m). As part of this process, the set "$BATS_ASSERTION_DISABLE_SHELL_OPTIONS"
and return_from_bats_assertion
mechanisms previously from lib/bats/assertions
have been generalized as set "$DISABLE_BATS_SHELL_OPTIONS
and restore_bats_shell_options
in the new lib/bats/helper-function
module.
After the first round of optimizations to the Bats framework itself, this time came down to O(1m25s). After the second round of Bats optimizations, the time came down to O(1m19s), for a total approximate speedup between 5.3x and 6x.
On Windows, the improvement is even more dramatic, given forking new processes on Windows is apparently over 50x more expensive than on UNIX. Running under VMWare Fusion (versions 8.5.3 to 8.5.5), the same go-script-bash test suite went from O(50m-60m) down to O(20+m) after the go-script-bash optimizations, down to O(3m40s-6m20s) after the first round of Bats optimizations, and down to O(3m21s-5m25s) after the second round of Bats optimizations, for a total approximate speedup between 9x and 18x. (Possibly more, but I don't want to spend the time getting the old numbers for an exact calculation!)
For more details, see the following artifacts:
lib/bats/function
from lib/bats/assertions
lib/bats/helper-function
library
optimized-20170205
tag comment from mbland/bats
optimized-20170317
tag comment from mbland/bats
lib/bats-main
test script libraryTo make it easier to write ./go test
commands with the same interface as that of the core library's ./go test
command—including test coverage reports via kcov and Coveralls—the lib/bats-main
library has been extracted from the core library's ./go test
script. It contains many user-overrideable variables, but basic usage is straightforward. See the header comments from lib/bats-main and the implementation of [./go test
][] for details.
Also, Bats is no longer integrated into the repository as a submodule. Instead, @go.bats_main
calls @go.bats_clone
to create a shallow clone of a Bats repository, configured via the _GO_BATS_DIR
, _GO_BATS_URL
, and _GO_BATS_VERSION
variables. (@go.bats_clone
uses the new @go get
command, described below, to create the clone.) By default, these variables are configured to clone the optimized Bats from mbland/bats
.
In addition to the test/Bats optimizations and the new lib/bats-main
library, other new test library features include:
_GO_INJECT_SCRIPT_PATH
and _GO_INJECT_MODULE_PATH
mechanism to stub core library scripts and modules, rather than the much riskier former implementation. (#118, #121) See the sections below on "Improved command script search and _GO_USE_MODULES
semantics" and "npm-like plugin semantics", as well as ./go help commands
and ./go modules -h
for further details.@go.test_compgen
helper function from lib/testing/environment makes it easier to generate expected tab completion results, and fails loudly to prevent test setup errors.stub_program_in_path
from lib/bats/helpers now works for testing in-process functions (as opposed to running scripts), and restore_program_in_path
has been added to help with cleanup and to guard against errors when stubbed program names are mistyped.DEBUG
traps set by Bats to collect and display stack trace information.go-template
bootstrap scriptThe new go-template
file provides the boilerplate for a standard project ./go
script. Basically, copying this script into your project and running it is all you need to do to get started using the go-script-bash framework right away, as it will take care of cloning the go-script-bash
framework into your project without the need to add it as a Git submodule. It contains several configuration variables, and any other project or application logic may be added to it as needed.
See the "How to use this framework" section of the README and the comments from go-template for details.
_GO_STANDALONE
modeThe _GO_STANDALONE
variable, when set, enables "Standalone" mode, whereby a ./go
script acts as an arbitrary application program rather than a project management script. In fact, a standalone application program can have its own project management ./go
script in the same repository.
See the "Standalone mode" section of the README for more information.
_GO_USE_MODULES
semanticsThe command script search and . "$_GO_USE_MODULES"
library module importation mechanism now implement the following precedence rules:
_GO_INJECT_SEARCH_PATH
and _GO_INJECT_MODULE_PATH
for stubs injected during testing_GO_CORE_DIR/libexec
and _GO_CORE_DIR/lib
for core library command scripts
and modules_GO_SCRIPTS_DIR
and _GO_SCRIPTS_DIR/lib
for command scripts and project-internal modules_GO_ROOTDIR/lib
for publicly-exported modules (if the project is a go-script-bash plugin)_GO_SCRIPTS_DIR/plugins/*/{bin,lib}
for command scripts and library modules from installed plugins_GO_PLUGINS_DIR/*/{bin,lib}
for plugin command scripts and library modulesThis reflects a more natural, predictable search order, and the . "$_GO_USE_MODULES"
mechanism now pinpoints potential module import collisions with a verbose warning message. See ./go help commands
and ./go modules -h
for more details.
get
and new
The ./go get file
command makes it easy to fetch a single file over the network using curl
, wget
, or FreeBSD's fetch
, and ./go get git-repo
creates a shallow clone of a Git repository (notably used by the lib/bats-main
and lib/kcov-ubuntu
libraries).
The ./go new
command makes it easy to create a new command script (--command
), internal library module (--internal
), public library module (--public
), or Bats test file (--test
), with minimal boilerplate. It can also create any other arbitrary file via the --type
option, so that users can reuse the command to generate their own boilerplate files and benefit from the same safety checks, error reporting, and automatic EDITOR
opening.
See ./go help get
and ./go help new
for more information.
The pull requests associated with #120 implement a new plugin protocol very similar to the node_modules
search mechanism implemented by npm. The new @go.search_plugins
function from go-core.bash
implements this algorithm, and is used by . "$_GO_USE_MODULES"
and the logic that builds the command script search paths. See ./go help plugins
and the comments for @go.search_plugins
for more details.
A forthcoming release will add documentation and tooling to make it easier to work with plugins.
@go.select_option
and demoThe @go.select_option
function added to go-core.bash
in #141 makes it easy to write interactive prompts for the user to select an item from a list of options. Run ./go demo-core select-option
to see it in action.
@go.printf
no longer adds a newline unconditionally, and no longer harbors a latent infinite loop bug (#146, #149).stub_program_in_path
from lib/bats/helpers now avoids calling the program it's trying to stub by generating the stub before setting PATH
and calling hash
(#168).You can see the details of every change by issuing one or more of the following commands after cloning: https://github.com/mbland/go-script-bash
$ ./go changes v1.3.0 v1.4.0 $ gitk v1.3.0..HEAD
This is a massive feature update that greatly extends the capabilities of the log
module, improves existing test helpers and adds many new ones, adds several new modules available via _GO_USE_MODULES
, plus much more. (And it goes without saying there are tons of bug fixes and compatibility workarounds!)
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
All of the issues and pull requests for this release are visible in the v1.3.0 milestone. Many of the new features were inspired by the enthusiastic and thoughtful input from John Omernik, based on his experience integrating the framework into his JohnOmernik/zetago project.
lib/log
updateslib/log
gained a number of powerful new features in this update:
_GO_LOG_TIMESTAMP_FORMAT
.@go.log_add_output_file
._GO_LOG_LEVEL_FILTER
and _GO_LOG_CONSOLE_FILTER
help control the amount of information logged to files or to the console, respectively.DEBUG
log level isn't emitted by default; use one of the above filters or @go.log_add_output_file
to capture it.QUIT
log level exits the process like FATAL
, but without a stack trace.@go.log_command
now captures all command output (even from subprocesses!) and emits it across all file descriptors configured for the RUN
log level.@go.critical_section_begin
now takes an argument to determine whether failing commands run under @go.log_command
will log QUIT
or FATAL
upon error; the default is set by _GO_CRITICAL_SECTION_DEFAULT
, which defaults to FATAL
demo-core log
builtin subcommand provides an interactive demonstration of log
module features; see ./go help demo-core log
.lib/testing/log
and lib/testing/stack-trace
.See ./go modules -h log
for more information.
lib/file
module for file descriptor-based file I/OThe new lib/file
functions make it easy to open, write to, and close file descriptors in a safe and convenient fashion. While most of these functions support the new lib/log
features, they are general-purpose and available to import via . "$_GO_USE_MODULES" file
. See ./go modules -h file
for more information.
lib/validation
file to validate caller-supplied dataThe functions from lib/validation
help make sure that caller-supplied data and variable names are well-formed and won't execute arbitrary code. The *_or_die
variations will exit with a stack trace if an item violates validation constraints. Useful for examining identifiers before invoking eval
or builtins such as printf -v
that expect an identifier name as an argument. See ./go modules -h validation
for more information.
lib/bats
module and the new lib/testing
module for testingIt's now easier than ever to compose new assertions from lib/bats/assertions
, thanks to the new set "$BATS_ASSERTION_DISABLE_SHELL_OPTIONS"
and return_from_bats_assertion
convention. New assertions are also easier to test thanks to the new lib/bats/assertion-test-helpers
utilities.
lib/bats/assertions
now contains:
fail_if
assertion negator for lib/bats/assertions
assertions, which makes it easy to write negative conditions with robust outputassert_lines_match
assertionset_bats_output_and_lines_from_file
, which is used to implement the new assert_file_equals
, assert_file_matches
, and assert_file_lines_match
assertionsGoodies now available in lib/bats/helpers
include:
fs_missing_permission_support
and skip_if_cannot_trigger_file_permission_failure
for skipping test cases on platforms that cannot trigger file permission-based conditionstest_join
for joining multiple expected output elements into a single variabletest_printf
and the TEST_DEBUG
variable for producing targeted test debugging outputtest_filter
and the TEST_FILTER
variable for pinpointing specific test cases within a suite and skipping the restsplit_bats_output_into_lines
to ensure blank lines from output
are preserved in lines
; this facilitates using assert_lines_equal
and assert_lines_match
with output containing blank linesstub_program_in_path
to easily write temporary test stubs for programs in PATH
Also, framework-specific test helpers have been exported to lib/testing
, to help with writing tests that depend on core framework output and behavior, including functions that help validate stack trace and @go.log
output.
All existing and new test helper functions have also been thoroughly tested on multiple platforms to ensure portability, ease-of-use, and a minimum of surprises.
lib/format
updatesThe lib/format
module gained two new functions:
@go.array_printf
for transforming an entire array of items at once using printf -v
@go.strip_formatting_codes
for removing ASCII formatting codes from a string, used by @go.log
when writing to non-console file descriptors in the absence of _GO_LOG_FORMATTING
Also, @go.pad_items
and @go.zip_items
have updated interfaces that expect the caller to provide the name of the output variable, now that both are defined in terms of @go.array_printf
(which is in turn implemented using the new @go.split
, described below.) See ./go modules -h format
for more information.
lib/strings
modulesThe lib/strings
module provides @go.split
and @go.join
functions that implement behavior common to other programming language libraries. See ./go modules -h strings
for more information.
@go.split
in particular is highly recommend for widespread use to avoid an obscure Bash bug on Travis CI; see the function comments and git show 99ab78 2297b4
for details.
_GO_USE_MODULES
exported for subprocess useNow any Bash process spawned by the ./go
script has access to the _GO_USE_MODULES
mechanism, most notably Bats test cases and assertions.
demo-core
framework and lib/subcommands
moduleThe lib/subcommands
module exports the @go.show_subcommands
function, which may be used to implement commands that are only shells for a number of subcommands. See ./go modules -h subcommands
for more information.
The new demo-core
command demonstrates the use of @go.show_subcommands
, and provides a framework for writing small demonstration programs for module features. As a first step, the demo-core log
subcommand provides a demonstration of various log
module features. See ./go help demo-core
and ./go help demo-core log
for more information.
@go.printf
works independently of fold
@go.printf
no longer opens a pipe to the fold
program, and now folds lines itself. The performance difference was a very minor improvement or degradation across systems, and now output is folded regardless of the presence of fold
on the host system.
[
instead of [[
in all Bats test casesTurns out there's a gotcha when using [[
in Bats test cases under Bash versions lower than 4.1, such as the stock 3.2.57(1)-release that ships on macOS. See git show fefce2
for details.
$'\x1f'
) instead of NUL to export arraysPreviously, $'\0'
was used to export the _GO_CMD_NAME
and _GO_CMD_ARGV
arrays to commands written in other languages. However, it wasn't possible to successfully use NUL to implement the new @go.array_printf
in the lib/format
module, or to pass it as a delimiter to @go.split
from the new lib/strings
module, since Bash can join strings using IFS=$'\0'
, but not split them. (Setting IFS=$'\0'
is equivalent to setting it to the null string, which disables word splitting.) Consequently, the ASCII Unit Separator character seemed a fine substitute for that purpose, and it seemed wise to apply it to _GO_CMD_NAME
and _GO_CMD_ARGV
as well.
You can see the details of every change by issuing one or more of the following commands after cloning: https://github.com/mbland/go-script-bash
$ ./go changes v1.2.1 v1.3.0 $ gitk v1.2.1..HEAD
This release enhances the public stack trace feature and adds it to @go.log FATAL
output.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
@go.print_stack_trace
take a numerical skip_callers
argumentPreviously @go.print_stack_trace
would only skip the immediate caller if the first argument was not null. Now it enforces that the number be a positive integer, in order to skip over the specified number of callers while printing the stack trace. This was done to support better @go.log FATAL
output, described below.
Normally an API change like this would warrant a major version bump, but since the impact should be minimal, it any potential for impact exists at all, it's included in this patch release.
@go.log FATAL
conditions@go.log FATAL
now prints a stack trace before exiting the process, since such information is generally useful under FATAL
conditions. Every function in the log
module that calls @go.log FATAL
removes itself from the stack trace, so the top of the stack shows the location of the user code that triggered the condition, rather than the location of the log
module function.
b2ad688 Mike BlandMerge pull request #28 from mbland/stack-trace 965782d Mike Bland log: Add stack trace to FATAL output a0f4413 Mike Bland stack-trace: Move, add helpers to environment.bash cd57da0 Mike Bland print-stack-trace: Add go-core stack test helper 8424338 Mike Bland print_stack_trace: Make skip_callers arg numerical
This release adds a stack trace feature to the public API.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
The @go.print_stack_trace
function is now part of the public API. Its original use case was to provide more helpful error messages from . "$_GO_USE_MODULES"
, but it's generally useful. See the function comments in go-core.bash
and ./go test --edit core/print-stack-trace
for more information.
fb6f3ae Mike BlandMerge pull request #27 from mbland/stack-trace 30790c9 Mike Bland use: Show stack trace when an import fails 8563f4d Mike Bland core: Add @go.print_stack_trace to public API
This is a bugfix release.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
. "$_GO_USE_MODULES"
Previously, the $_GO_USE_MODULES
script would report an Unknown module:
error in every error case, even if the module existed but failed for another reason (Issue #25). The module's standard error would also get redirected to /dev/null
, which made diagnosis even more difficult.
Now any modules that actually exist but return an error when imported will be identified as such, rather than being reported as unknown, and standard error isn't redirected at all (PR #26).
22bace2 Mike BlandMerge pull request #26 from mbland/module-import 8833762 Mike Bland use: Improve module import error message 4bb94e2 Mike Bland use: Nest module file path tests 92bc468 Mike Bland use: Detect module path before sourcing 5ea7820 Mike Bland modules: Fix incorrect help text
This is a bugfix release.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
echo -e
with printf
On at least one macOS 10.12.1 installation, echo -e
under Bash 3.2.57(1)-release in Terminal.app wasn't converting \e
sequences to actual ANSI escape sequences. Using printf
instead resolves the issue.
187715e Mike BlandMerge pull request #24 from mbland/printf-esc-seqs 4bc05c8 Mike Bland log: Replace `echo -e` with `printf`
This release adds some major new features, two new builtin commands, and multiple bug fixes and internal improvements.
./go
script: a unified development environment interfaceSource: https://github.com/mbland/go-script-bash
A ./go
script aims to abstract away many of the steps needed to develop (and sometimes deploy) a software project. It is a replacement for READMEs and other documents that may become out-of-date, and when maintained properly, should provide a cohesive and discoverable interface for common project tasks.
The ./go
script idea came from Pete Hodgson's blog posts In Praise of the ./go Script: Part I and Part II.
Note: The ./go
script concept is completely unrelated to the Go programming language, though the Go language's go
command encapsulates many common project functions in a similar fashion.
This software is made available as Open Source software under the ISC License. If you'd care to contribute to this project, be it code fixes, documentation updates, or new features, please read the CONTRIBUTING.md
file.
You can import optional Bash library code from the core framework, third-party plugins, or your own project's scripts directory by sourcing the _GO_USE_MODULES
script. See the Modules section of the README or run ./go help modules
and ./go modules --help
for more information.
The core library log
module provides functions for standard logging facilities. For more information, see the Logging section from the README and run ./go modules --help log
.
The assertions and helpers from the test suite have been extracted into the lib/bats/assertions
and lib/bats/helpers
libraries. See the Bats test assertions and helpers section from the README and read the comments from each file for more information.
kcov-ubuntu
module for test coverage on LinuxThe kcov-ubuntu
module provides the run_kcov
function that uses kcov to collect test coverage on Ubuntu Linux. See the kcov-ubuntu
module for test coverage on Linux section of the README and run ./go modules --help kcov-ubuntu
for more information.
_GO_*
variables and the vars
builtin commandA number of global variables starting with the prefix _GO_*
are exported as environment variables and are available to command scripts in all languages. See the Command script API section from the README and run ./go help vars
for more information.
9411a89 Mike BlandMerge pull request #23 from mbland/version e8ef35b Mike Bland core: Introduce _GO_CORE_VERSION 17a69d2 Mike Bland Add documentation improvements for v1.1.0 release ecd2d81 Mike Bland use: Unset correct variable 006c38b Mike Bland Merge pull request #22 from mbland/remove-stale-files e17c181 Mike Bland Remove old test `./go` scripts f9675e5 Mike Bland Merge pull request #21 from mbland/plugins 33c54b6 Mike Bland plugins: Revert changes from #20 ce20155 Mike Bland Merge pull request #20 from mbland/vars 6b376eb Mike Bland vars: Make test array quotifying more robust 241d2c7 Mike Bland Revamp `_GO_*` var exports, add `vars` builtin 7c1123b Mike Bland Move all _GO_* vars to core and document them 17beb1e Mike Bland Merge pull request #19 from mbland/assert-lines-equal 70d546f Mike Bland assertions: Add assert_lines_equal 32d47fc Mike Bland changes: Don't add `^` to end ref 580f08d Mike Bland core: Tweak COLUMNS test slightly 47b6e63 Mike Bland Merge pull request #18 from mbland/columns 5292839 Mike Bland core: Fix test for OS X on Travis without /dev/tty c7ee892 Mike Bland core: Reproduce and fix `tput cols` error from #17 664a51f Mike Bland Merge pull request #17 from mbland/columns 5bdbd2c Mike Bland core: Update how COLUMNS is set 5fc49a5 Mike Bland log: Skip setup-project test case on MSYS2 0e91281 Mike Bland Merge pull request #16 from mbland/log-setup ecb6b83 Mike Bland log: Fix @go.critical_section_end return bug b7f7699 Mike Bland log: Add @go.setup_project function ed05f2b Mike Bland Merge pull request #15 from mbland/log-command da20203 Mike Bland log: Add log_command tests for @go command cases db79ba1 Mike Bland log: Add @go.log_command, critical section flag 43fae60 Mike Bland Merge pull request #14 from mbland/add-or-update-log-level 949fb32 Mike Bland log: Implement @go.add_or_update_log_level dd712c6 Mike Bland Merge pull request #13 from mbland/log 0a7bc5e Mike Bland lib/log: Add logging module 31a1d30 Mike Bland complete: Fix typo in internal library comment 3cc22b0 Mike Bland Merge pull request #12 from mbland/assertions 0d94845 Mike Bland Revert previous two commits f4a0f85 Mike Bland assertions: Reset return trap when trap exits 7ca3d05 Mike Bland assertions: Introduce bats_assertion_return_trap 40d6218 Mike Bland assertions: Make public return_from_bats_assertion 87bb07c Mike Bland assertions: Reproduce and fix latent functrace bug 52bc541 Mike Bland Merge pull request #11 from mbland/complete 112e046 Mike Bland env/bash: Put single quotes around unset argument e7f02fe Mike Bland complete: Eliminate compgen from internal library 096f0f3 Mike Bland bats/assertions: Change double quotes to single d8e4231 Mike Bland complete: Replace most compgen calls with echo 4d61457 Mike Bland complete: Switch all tests to use ./go complete 54e8e9a Mike Bland Merge pull request #10 from mbland/tput-fix-test-docs e779deb Mike Bland test: Expand comments, refactor slightly b9792bf Mike Bland kcov-ubuntu: Update run_kcov function comment 4c66893 Mike Bland core: Undo tput error redirect 676dd18 Mike Bland Merge pull request #9 from mbland/bats-libs 69fb63b Mike Bland bats/assertions: Reorder functions, add docs d692bb9 Mike Bland bats/assertions: Add optional fail() reason, docs ac8ed3f Mike Bland tests: Extract public bats/assertions module 2707493 Mike Bland tests: Consolidate environment.bash c77932e Mike Bland kcov: Convert to public kcov-ubuntu module 1a47920 Mike Bland cmd-desc: Remove create_test_command_script calls 3deee25 Mike Bland run-cmd: Update _GO_* var tests to run subcommands 4168b58 Mike Bland Extract public bats/helpers module 87ce40a Mike Bland Merge pull request #8 from mbland/cmd-name-argv 202b17c Mike Bland core: Export _GO_CMD_{NAME,ARGV}, add Bash test d674191 Mike Bland Merge pull request #7 from mbland/cmd-desc 9bd1524 Mike Bland core: Default to 80 columns on all tput errors 47d9476 Mike Bland TEMP: Print value of $TERM to debug Travis issue 271c726 Mike Bland core: Check $TERM before setting columns with tput c1ba9c8 Mike Bland cmd_desc: Show full command names in descriptions c2098c4 Mike Bland Merge pull request #6 from mbland/core-updates 2777ca8 Mike Bland core: Export variables for non-Bash script access 1158bc7 Mike Bland core: Escape % when only one @go.printf argument 995daf0 Mike Bland script_helper: Default to bash, allow other langs 6444f51 Mike Bland Merge pull request #5 from mbland/modules-builtin 0a4886a Mike Bland README: ./go modules help => ./go modules --help 78c447a Mike Bland test, modules: Quote $_GO_USE_MODULES, add docs 9bb7a45 Mike Bland Add modules builtin command 766a354 Mike Bland command_descriptions: Trim trailing whitespace e764723 Mike Bland command_descriptions: Return error if read fails 7cd5dd5 Mike Bland kcov: Add note explaining 2>/dev/null redirection 80b7abe Mike Bland test: Use time builtin 4c8f931 Mike Bland complete: Add public module, completion removal 97fd0df Mike Bland test/script_helper: Add TEST_GO_PLUGINS_DIR 2d88f57 Mike Bland format: Add public module, pad and zip functions 8c23dcd Mike Bland Merge pull request #3 from mbland/lightning-talk 4f1e6c6 Mike Bland README: Update location of lib/internal/env 515730d Mike Bland README: Add link to Surge 2016 lightning talk 2cbfdda Mike Bland Merge pull request #2 from mbland/use-modules a5973af Mike Bland use: Fix test for bash test: Replace direct source with _GO_USE_MODULES ed78d9f Mike Bland core: Add _GO_USE_MODULES for optional modules 2d5cb96 Mike Bland Merge pull request #1 from mbland/refactor 345dd55 Mike Bland Lowercase __go_orig_dir, unset temp globals e6c29fd Mike Bland Move all lib/ files to lib/internal/ 1634d85 Mike Bland core: Refactor, update comments