🦊 Exit status 1 on cancelled selection (#20)

When making no selection, i.e. cancelling during the selection process
the program will return status code 1, whereas before it would carry the
same return code as when making an emoji selection.

Fixes #20.
This commit is contained in:
Marty Oehme 2023-04-11 22:05:16 +02:00
parent 32fc9f45dd
commit 71d5dc455d
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 9 additions and 2 deletions

View file

@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
<!-- ### Added --> ### Added
- Pass through return code 1 from selection tool
### Changed ### Changed

2
bemoji
View file

@ -206,7 +206,7 @@ result=$(echo "$result" | grep -o '^\S\+' | tr -d '\n')
case "$exit_value" in case "$exit_value" in
1) 1)
exit exit 1
;; ;;
0) 0)
if [ ${#bm_cmds[@]} -eq 0 ]; then if [ ${#bm_cmds[@]} -eq 0 ]; then

View file

@ -64,6 +64,11 @@ typing result"
assert_output "my clipping" assert_output "my clipping"
} }
@test "Returns status code 1 on picker status code 1" {
BEMOJI_PICKER_CMD="return 1" run bemoji -e 3>&-
assert_failure 1
}
@test "Prints output with newline by default" { @test "Prints output with newline by default" {
bats_require_minimum_version 1.5.0 bats_require_minimum_version 1.5.0
BEMOJI_PICKER_CMD="echo heart" run --keep-empty-lines -- bemoji -e BEMOJI_PICKER_CMD="echo heart" run --keep-empty-lines -- bemoji -e