Skip to content

Commit

Permalink
common-utils: assert_regex: Do not check if string is empty
Browse files Browse the repository at this point in the history
Totally defies the logic here
  • Loading branch information
Akianonymus committed Aug 4, 2022
1 parent 0f780d9 commit 95db89f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion release/bash/gdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SELF_SOURCE="true"
set -a
_assert_regex(){
declare pattern="${1:?Error: Missing pattern}" string="${2:?Missing string}"
declare pattern="${1:-}" string="${2:-}"
if [[ $string =~ $pattern ]];then
return 0
else
Expand Down
4 changes: 2 additions & 2 deletions release/sh/gdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
SELF_SOURCE="true"
set -a
_assert_regex(){
grep -qE "${1:?Error: Missing pattern}" 0<<EOF
${2:?Missing string}
grep -qE "${1:-}" 0<<EOF
${2:-}
EOF
}
_count(){
Expand Down
2 changes: 1 addition & 1 deletion src/bash/common-utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Result: return 0 or 1
###################################################
_assert_regex() {
declare pattern="${1:?Error: Missing pattern}" string="${2:?Missing string}"
declare pattern="${1:-}" string="${2:-}"
if [[ ${string} =~ ${pattern} ]]; then
return 0
else
Expand Down
4 changes: 2 additions & 2 deletions src/sh/common-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# Result: return 0 or 1
###################################################
_assert_regex() {
grep -qE "${1:?Error: Missing pattern}" 0<< EOF
${2:?Missing string}
grep -qE "${1:-}" 0<< EOF
${2:-}
EOF
}

Expand Down

0 comments on commit 95db89f

Please sign in to comment.