Skip to content

Commit efd42e5

Browse files
committed
Show useful error instead of unbound variable when --long option is missing a value
1 parent 84ba5fc commit efd42e5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ system, you must also run the `--upgrade` command in each repository:
5252
well as 4.4+, and even if some encrypted files are empty (#197)
5353
- Don't show message about unexpected dirty files after a `--rekey` because
5454
dirty files are expected (#201)
55+
- Show useful error instead of `unbound variable` when --long option is missing
56+
a value, e.g. `transcrypt --context`
5557

5658
## [2.3.1] - 2025-02-24
5759

transcrypt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,14 +1459,15 @@ while [[ "${1:-}" != '' ]]; do
14591459
exit $?
14601460
;;
14611461
-c | --cipher)
1462-
cipher=$2
1462+
cipher=${2:-}
1463+
[[ $cipher ]] || die 1 'empty cipher'
14631464
shift
14641465
;;
14651466
--cipher=*)
14661467
cipher=${1#*=}
14671468
;;
14681469
-p | --password)
1469-
password=$2
1470+
password=${2:-}
14701471
[[ $password ]] || die 1 'empty password'
14711472
shift
14721473
;;
@@ -1475,7 +1476,7 @@ while [[ "${1:-}" != '' ]]; do
14751476
[[ $password ]] || die 1 'empty password'
14761477
;;
14771478
--add)
1478-
add_pattern=$2
1479+
add_pattern=${2:-1}
14791480
[[ $add_pattern ]] || die 1 'empty pattern'
14801481
requires_clean_repo=''
14811482
shift
@@ -1486,7 +1487,8 @@ while [[ "${1:-}" != '' ]]; do
14861487
requires_clean_repo=''
14871488
;;
14881489
-C | --context)
1489-
context=$2
1490+
context=${2:-}
1491+
[[ $context ]] || die 1 'empty context'
14901492
shift
14911493
;;
14921494
--context=*)
@@ -1535,7 +1537,8 @@ while [[ "${1:-}" != '' ]]; do
15351537
requires_clean_repo=''
15361538
;;
15371539
-s | --show-raw)
1538-
show_file=$2
1540+
show_file=${2:-}
1541+
[[ $show_file ]] || die 1 'empty file path'
15391542
show_raw_file
15401543
exit 0
15411544
;;
@@ -1545,7 +1548,8 @@ while [[ "${1:-}" != '' ]]; do
15451548
exit 0
15461549
;;
15471550
-e | --export-gpg)
1548-
gpg_recipient=$2
1551+
gpg_recipient=${2:-}
1552+
[[ $gpg_recipient ]] || die 1 'empty recipient'
15491553
requires_existing_config='true'
15501554
requires_clean_repo=''
15511555
shift
@@ -1556,7 +1560,8 @@ while [[ "${1:-}" != '' ]]; do
15561560
requires_clean_repo=''
15571561
;;
15581562
-i | --import-gpg)
1559-
gpg_import_file=$2
1563+
gpg_import_file=${2:-}
1564+
[[ $gpg_import_file ]] || die 1 'empty import file'
15601565
shift
15611566
;;
15621567
--import-gpg=*)

0 commit comments

Comments
 (0)