Skip to content

Commit b0b979c

Browse files
authored
Merge pull request #446 from DannyBen/fix/strict-mode
Fix some incompatibilities with strict mode
2 parents 708d64e + e439c84 commit b0b979c

File tree

15 files changed

+28
-27
lines changed

15 files changed

+28
-27
lines changed

examples/config/src/lib/config.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
## - Use any of the following functions to access and manipulate the values.
99
## - INI sections are optional (i.e., sectionless key=value pairs are allowed).
1010
##
11-
1211
## Show all the key=value pairs from your config file
1312
config_show() {
1413
config_load
@@ -28,8 +27,8 @@ config_show() {
2827
## theme="$(config_get interface.theme)"
2928
##
3029
config_get() {
31-
local key="$1"
32-
local default_value="$2"
30+
local key="${1-}"
31+
local default_value="${2-}"
3332

3433
config_load
3534
echo "${ini["$key"]:-$default_value}"
@@ -40,7 +39,7 @@ config_get() {
4039
## config_set cloud.provider aws
4140
##
4241
config_set() {
43-
local key="$1"
42+
local key="${1-}"
4443
shift
4544
local value="$*"
4645

@@ -54,7 +53,7 @@ config_set() {
5453
## config_del login.email
5554
##
5655
config_del() {
57-
local key="$1"
56+
local key="${1-}"
5857

5958
config_load
6059
unset "ini[$key]"
@@ -93,7 +92,7 @@ config_reload() {
9392
## Load an INI file (unless loaded) and populate the associative array
9493
## NOTE: Normally there is no need to call this function, it is called as needed
9594
config_load() {
96-
[[ "$config_loaded" == "true" ]] && return
95+
[[ "${config_loaded-}" == "true" ]] && return
9796

9897
declare -g CONFIG_FILE=${CONFIG_FILE:=config.ini}
9998
declare -g config_loaded=true

examples/config/src/lib/ini.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
## unset ini[section1.key1]
2626
## ini_save path/to/config.ini
2727
##
28-
2928
## Load an INI file and populate the associative array `ini`.
3029
ini_load() {
3130
declare -gA ini

examples/help-command/src/help_command.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
## - name: command
1111
## help: Help subject
1212
##
13-
command="${args[command]}"
13+
command="${args[command]:-}"
1414
long_usage=yes
1515

1616
if [[ -z "$command" ]]; then

examples/ini/src/get_command.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Using the standard library (lib/ini.sh) to show a value from the config
22
ini_load config.ini
33

4-
key="${args[key]}"
5-
value=${ini[$key]}
4+
key="${args[key]:-}"
5+
value=${ini[$key]:-}
66

77
if [[ "$value" ]]; then
88
echo "$key = $value"

examples/ini/src/lib/ini.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
## unset ini[section1.key1]
2626
## ini_save path/to/config.ini
2727
##
28-
2928
## Load an INI file and populate the associative array `ini`.
3029
ini_load() {
3130
declare -gA ini

examples/render-mandoc/docs/download.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
. ftr VB CB
1515
. ftr VBI CBI
1616
.\}
17-
.TH "download" "1" "October 2023" "Version 0.1.0" "Sample application"
17+
.TH "download" "1" "November 2023" "Version 0.1.0" "Sample application"
1818
.hy
1919
.SH NAME
2020
.PP

examples/render-mandoc/docs/download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample application
22
% Lana Lang
3-
% October 2023
3+
% November 2023
44

55
NAME
66
==================================================

lib/bashly/libraries/config/config.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ config_show() {
2727
## theme="$(config_get interface.theme)"
2828
##
2929
config_get() {
30-
local key="$1"
31-
local default_value="$2"
30+
local key="${1-}"
31+
local default_value="${2-}"
3232

3333
config_load
3434
echo "${ini["$key"]:-$default_value}"
@@ -39,7 +39,7 @@ config_get() {
3939
## config_set cloud.provider aws
4040
##
4141
config_set() {
42-
local key="$1"
42+
local key="${1-}"
4343
shift
4444
local value="$*"
4545

@@ -53,7 +53,7 @@ config_set() {
5353
## config_del login.email
5454
##
5555
config_del() {
56-
local key="$1"
56+
local key="${1-}"
5757

5858
config_load
5959
unset "ini[$key]"
@@ -92,7 +92,7 @@ config_reload() {
9292
## Load an INI file (unless loaded) and populate the associative array
9393
## NOTE: Normally there is no need to call this function, it is called as needed
9494
config_load() {
95-
[[ "$config_loaded" == "true" ]] && return
95+
[[ "${config_loaded-}" == "true" ]] && return
9696

9797
declare -g CONFIG_FILE=${CONFIG_FILE:=config.ini}
9898
declare -g config_loaded=true

lib/bashly/libraries/help/help_command.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
## - name: command
1111
## help: Help subject
1212
##
13-
command="${args[command]}"
13+
command="${args[command]:-}"
1414
long_usage=yes
1515

1616
if [[ -z "$command" ]]; then

lib/bashly/views/command/whitelist_filter.gtx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
1212
> done
1313

1414
else
15-
> if [[ -n ${args['{{ arg.name }}']} ]] && [[ ! ${args['{{ arg.name }}']} =~ ^({{ arg.allowed.join '|' }})$ ]]; then
15+
> if [[ -n ${args['{{ arg.name }}']:-} ]] && [[ ! ${args['{{ arg.name }}']:-} =~ ^({{ arg.allowed.join '|' }})$ ]]; then
1616
> printf "%s\n" "{{ strings[:disallowed_argument] % { name: arg.name, allowed: arg.allowed.join(', ') } }}" >&2
1717
> exit 1
1818
> fi
@@ -31,7 +31,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
3131
> done
3232

3333
else
34-
> if [[ ${args['{{ flag.name }}']} ]] && [[ ! ${args['{{ flag.name }}']} =~ ^({{ flag.allowed.join '|' }})$ ]]; then
34+
> if [[ ${args['{{ flag.name }}']:-} ]] && [[ ! ${args['{{ flag.name }}']:-} =~ ^({{ flag.allowed.join '|' }})$ ]]; then
3535
> printf "%s\n" "{{ strings[:disallowed_flag] % { name: flag.name, allowed: flag.allowed.join(', ') } }}" >&2
3636
> exit 1
3737
> fi

0 commit comments

Comments
 (0)