Skip to content

Commit

Permalink
Before/After hooks should not consume stdin data
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Jun 19, 2020
1 parent db1c1f2 commit f1dccd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ shellspec_call_hook() {
;;
esac

eval "SHELLSPEC_HOOK=\$2 && $2 &&:" &&:
{ eval "SHELLSPEC_HOOK=\$2 && $2 &&:" &&:; } < /dev/null
SHELLSPEC_HOOK_STATUS=$?
return $SHELLSPEC_HOOK_STATUS
}
Expand Down
16 changes: 16 additions & 0 deletions spec/core/hook_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ Describe "core/hook.sh"
End
End

Describe 'shellspec_call_hook()'
example_hooks() {
shellspec_register_before_hook EXAMPLE cat
}

Data
#|dummy data
End

It 'does not consume stdin data.'
BeforeCall example_hooks
When call shellspec_call_before_hooks EXAMPLE
The stdout should be blank
End
End

Describe 'shellspec_mark_group()'
Before "shellspec_mark_group 12345"

Expand Down

0 comments on commit f1dccd3

Please sign in to comment.