Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions examples/stacktrace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ examples:
## before running anything else.
##
## You can safely delete this file if you do not need it.
trap 'stacktrace' ERR
set -o errtrace
enable_stacktrace

````

Expand Down Expand Up @@ -118,8 +117,8 @@ Examples:

Stack trace:
from ./download:15 in `root_command`
from ./download:254 in `run`
from ./download:260 in `main`
from ./download:260 in `run`
from ./download:266 in `main`


````
Expand Down
3 changes: 1 addition & 2 deletions examples/stacktrace/src/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
## before running anything else.
##
## You can safely delete this file if you do not need it.
trap 'stacktrace' ERR
set -o errtrace
enable_stacktrace
16 changes: 8 additions & 8 deletions examples/stacktrace/src/lib/stacktrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
## Usage:
## This function is designed to be called on error.
##
## To enable this functionality, add these lines to your `src/initialize.sh`
## file (Run `bashly add hooks` to add this file):
##
## trap 'stacktrace' ERR
## set -o errtrace
##
## Note that this functionality also requires `set -e`, which is enabled by
## default in bashly generated scripts.
## To enable this functionality, call `enable_stacktrace` in your
## `src/initialize.sh` (Run `bashly add hooks` to add this file).
##
enable_stacktrace() {
trap 'stacktrace' ERR
set -o errtrace
set -o errexit
}

stacktrace() {
local exit_status="$?"
local i=0
Expand Down
8 changes: 4 additions & 4 deletions lib/bashly/libraries/libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ stacktrace:
post_install_message: |
The stacktrace function is designed to be called automatically on error.
To enable this functionality, add these lines to your `initialize.sh`:
g`trap 'stacktrace' ERR`
g`set -o errtrace`
To enable this functionality, call g`enable_stacktrace` in your
g`src/initialize.sh`. You may run the following command to add this file:
m`$ bashly add hooks`
strings:
help: Copy an additional configuration file to your project, allowing you to customize all the tips and error strings.
Expand Down
16 changes: 8 additions & 8 deletions lib/bashly/libraries/stacktrace/stacktrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
## Usage:
## This function is designed to be called on error.
##
## To enable this functionality, add these lines to your `src/initialize.sh`
## file (Run `bashly add hooks` to add this file):
##
## trap 'stacktrace' ERR
## set -o errtrace
##
## Note that this functionality also requires `set -e`, which is enabled by
## default in bashly generated scripts.
## To enable this functionality, call `enable_stacktrace` in your
## `src/initialize.sh` (Run `bashly add hooks` to add this file).
##
enable_stacktrace() {
trap 'stacktrace' ERR
set -o errtrace
set -o errexit
}

stacktrace() {
local exit_status="$?"
local i=0
Expand Down
10 changes: 5 additions & 5 deletions spec/approvals/examples/stacktrace
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ created src/lib/stacktrace.sh

The stacktrace function is designed to be called automatically on error.

To enable this functionality, add these lines to your `initialize.sh`:
To enable this functionality, call enable_stacktrace in your
src/initialize.sh. You may run the following command to add this file:

trap 'stacktrace' ERR
set -o errtrace
$ bashly add hooks

+ bashly generate
creating user files in src
Expand Down Expand Up @@ -51,5 +51,5 @@ Examples:

Stack trace:
from ./download:15 in `root_command`
from ./download:255 in `run`
from ./download:261 in `main`
from ./download:260 in `run`
from ./download:266 in `main`