File tree Expand file tree Collapse file tree 3 files changed +25
-11
lines changed Expand file tree Collapse file tree 3 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -44,13 +44,14 @@ bash_object.traverse-set() {
44
44
if [ -z " ${current_object["$key"]+x} " ]; then
45
45
# If we are before the last element in the query, then error
46
46
if (( i+ 1 < ${# REPLIES[@]} )) ; then
47
- bash_object.util.die ' ERROR_VALUE_NOT_FOUND' " Key or index '$key ' is not in '$filter_stack_string '"
48
- return
47
+ bash_object.util.die ' ERROR_VALUE_NOT_FOUND' " Key or index '$key ' is not in '$filter_stack_string '"
48
+ return
49
49
# If we are at the last element in the query
50
50
elif (( i+ 1 == ${# REPLIES[@]} )) ; then
51
51
if [ " $final_value_type " = object ]; then
52
52
# TODO: test this
53
- if bash_object.ensure.variable_does_exist " $final_value " ; then : ; else
53
+ # shellcheck disable=SC1087
54
+ if bash_object.ensure.variable_does_exist " $final_value [@]" ; then : ; else
54
55
return
55
56
fi
56
57
@@ -83,7 +84,8 @@ bash_object.traverse-set() {
83
84
done
84
85
elif [ " $final_value_type " = array ]; then
85
86
# TODO: test this
86
- if bash_object.ensure.variable_does_exist " $final_value " ; then : ; else
87
+ # shellcheck disable=SC1087
88
+ if bash_object.ensure.variable_does_exist " $final_value [@]" ; then : ; else
87
89
return
88
90
fi
89
91
Original file line number Diff line number Diff line change @@ -5,12 +5,22 @@ bash_object.ensure.variable_is_valid() {
5
5
return 0
6
6
}
7
7
8
- # TODO: swap with does_not
8
+ # @description Ensure the variable already exists. Note that the variable _must_ be sanitized before using this function
9
9
bash_object.ensure.variable_does_exist () {
10
- if bash_object.ensure.variable_does_not_exist " $1 " ; then
11
- bash_object.util.die ' ERROR_INTERNAL_MISCELLANEOUS' " Variable '$1 ' does not exist, but it should"
10
+ local variable_name=" $1 "
11
+
12
+ if [ -z " $variable_name " ]; then
13
+ bash_object.util.die " ERROR_INTERNAL_MISCELLANEOUS" " Parameter to function 'bash_object.ensure.variable_does_exist' was empty"
12
14
return
15
+ fi
16
+
17
+ if (( BASH_VERSINFO[0 ] >= 5 )) || (( BASH_VERSINFO[0 ] == 4 && BASH_VERSINFO[1 ] >= 2 )) ; then
18
+ if [[ ! -v " $variable_name " ]]; then
19
+ bash_object.util.die ' ERROR_INTERNAL_MISCELLANEOUS' " Variable '$variable_name ' does not exist, but it should"
20
+ return
21
+ fi
13
22
else
23
+ # TODO
14
24
:
15
25
fi
16
26
}
Original file line number Diff line number Diff line change @@ -19,17 +19,19 @@ bash_object.util.die() {
19
19
local error_output=
20
20
case " $error_key " in
21
21
ERROR_INVALID_FILTER)
22
- printf -v error_output ' Failed to perform operation :
22
+ printf -v error_output ' Failed to parse filter :
23
23
-> code: %s
24
24
-> message: %s
25
25
-> context: %s
26
- -> PARSER_COLUMN_NUMBER: %s' " $error_key " " $error_message " " $error_context " " $PARSER_COLUMN_NUMBER "
26
+ -> PARSER_COLUMN_NUMBER: %s
27
+ ' " $error_key " " $error_message " " $error_context " " $PARSER_COLUMN_NUMBER "
27
28
;;
28
29
* )
29
- printf -v error_output ' Failed to parse filter :
30
+ printf -v error_output ' Failed to perform operation :
30
31
-> code: %s
31
32
-> message: %s
32
- -> context: %s' " $error_key " " $error_message " " $error_context "
33
+ -> context: %s
34
+ ' " $error_key " " $error_message " " $error_context "
33
35
;;
34
36
esac
35
37
You can’t perform that action at this time.
0 commit comments