Skip to content

Commit

Permalink
Remove call/invoke <STRING> syntax
Browse files Browse the repository at this point in the history
It become unnecessary in the implementation of DATA
  • Loading branch information
ko1nksm committed Jul 18, 2019
1 parent d43e03b commit b9e5553
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Drop support for busybox 1.1.3 and similar versions as it can not redefine builtin commands.
- Drop support for ash 0.3.8 and similar versions as it can not use retrun in sourced script.
- Remove `call`/`invoke` `<STRING>` syntax.

## [0.18.0] - 2019-07-09

Expand Down
14 changes: 6 additions & 8 deletions docs/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ You can write structured *Example* by below DSL.

The line start with `When` is the evaluation. The evaluation type follows after `When`.

| evaluation type | Description |
| :--------------------------------- | :--------------------------------------------------- |
| call `<FUNCTION> [ARGUMENTS...]` | Call shell function or external command. |
| call `<STRING> [ARGUMENTS...]` | Eval string and execute. |
| invoke `<FUNCTION> [ARGUMENTS...]` | Call shell function or external command in subshell. |
| invoke `<STRING> [ARGUMENTS...]` | Eval string and execute in subshell. |
| run `<FUNCTION> [ARGUMENTS...]` | Run external command. |
| execute `<SCRIPT> [ARGUMENTS...]` | Execute shell script file. |
| evaluation type | Description |
| :------------------------------------------ | :--------------------------------------------------- |
| call `<FUNCTION | COMMAND> [ARGUMENTS...]` | Call shell function or external command. |
| invoke `<FUNCTION| COMMAND> [ARGUMENTS...]` | Call shell function or external command in subshell. |
| run `<COMMAND> [ARGUMENTS...]` | Run external command. |
| execute `<SCRIPT> [ARGUMENTS...]` | Execute shell script file. |

Normally you will use `call`. `invoke` is similar to `call` but execute in subshell.
`invoke` usefull for *override function in evaluation only* and trap `exit`.
Expand Down
10 changes: 0 additions & 10 deletions lib/core/evaluation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ shellspec_syntax 'shellspec_evaluation_execute'
shellspec_proxy 'shellspec_evaluation' 'shellspec_syntax_dispatch evaluation'

shellspec_evaluation_call() {
if ! shellspec_is funcname "$1"; then
eval "shellspec_evaluation_eval() { $1; }"
shift
eval set -- shellspec_evaluation_eval ${1+'"$@"'}
fi
if [ "${SHELLSPEC_DATA:-}" ]; then
set -- shellspec_evaluation_with_data "$@"
fi
Expand All @@ -38,11 +33,6 @@ shellspec_evaluation_run() {
shellspec_around_invoke() { "$@"; }

shellspec_evaluation_invoke() {
if ! shellspec_is funcname "$1"; then
eval "shellspec_evaluation_eval() { $1; }"
shift
eval set -- shellspec_evaluation_eval ${1+'"$@"'}
fi
if [ "${SHELLSPEC_DATA:-}" ]; then
set -- shellspec_evaluation_with_data "$@"
fi
Expand Down
10 changes: 0 additions & 10 deletions spec/core/evaluation_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ Describe "core/evaluation.sh"
The stdout should equal 'cleanup: 123'
End

It 'accepts evaluatable string'
When call 'echo "$@"' 1 2 3
The stdout should equal '1 2 3'
End

It 'ensures errno 0 before evaluating function'
relay_errno() { return ${?}; }
When call relay_errno
Expand Down Expand Up @@ -118,11 +113,6 @@ Describe "core/evaluation.sh"
The stdout should equal 'cleanup: 123'
End

It 'accepts evaluatable string'
When invoke 'echo "$@"' 1 2 3
The stdout should equal '1 2 3'
End

It 'ensures errno 0 before calling external command'
shellspec_around_invoke() { "$@"; }
relay_errno() { return ${?}; }
Expand Down

0 comments on commit b9e5553

Please sign in to comment.