From 6ba332f34526819d06461704c57b7642f0f1e024 Mon Sep 17 00:00:00 2001 From: Nikolaos Kakouros Date: Wed, 18 Nov 2020 16:08:51 +0100 Subject: [PATCH] Allows negative indexes in line assertions --- src/assert_line.bash | 2 +- src/refute_line.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assert_line.bash b/src/assert_line.bash index c0f68de..ee05bb8 100644 --- a/src/assert_line.bash +++ b/src/assert_line.bash @@ -137,7 +137,7 @@ assert_line() { while (( $# > 0 )); do case "$1" in -n|--index) - if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then + if (( $# < 2 )) || ! [[ $2 =~ ^-?([0-9]|[1-9][0-9]+)$ ]]; then echo "\`--index' requires an integer argument: \`$2'" \ | batslib_decorate 'ERROR: assert_line' \ | fail diff --git a/src/refute_line.bash b/src/refute_line.bash index c9aa47f..689bea1 100644 --- a/src/refute_line.bash +++ b/src/refute_line.bash @@ -140,7 +140,7 @@ refute_line() { while (( $# > 0 )); do case "$1" in -n|--index) - if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then + if (( $# < 2 )) || ! [[ $2 =~ ^-?([0-9]|[1-9][0-9]+)$ ]]; then echo "\`--index' requires an integer argument: \`$2'" \ | batslib_decorate 'ERROR: refute_line' \ | fail