Skip to content

Commit 5882be2

Browse files
committed
fix(hook-augment): bail on rtk grep -l per maintainer requirement
rtk grep adds its own -l <N> that shadows grep's valueless -l, making the pattern position ambiguous. Fail closed instead of guessing. Removes l from the rtk_grep val_flags string and adds an explicit return false when rtk && bin == HA_BIN_GREP && flag == 'l'. Test flipped from ASSERT_TRUE to ASSERT_FALSE. Signed-off-by: Jake Abendroth <contact@jakea.net>
1 parent eb12d6d commit 5882be2

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/cli/hook_augment.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ static const char *ha_search_bin_val_flags(ha_bin_t bin, bool rtk_grep) {
10861086
case HA_BIN_AG:
10871087
return "ABCmpG";
10881088
default:
1089-
return rtk_grep ? "ABCmdDl" : "ABCmdD";
1089+
return "ABCmdD";
10901090
}
10911091
}
10921092

@@ -1196,6 +1196,8 @@ static bool ha_parse_bash_search_pattern(const char *cmd, char *out, size_t out_
11961196
e_count++;
11971197
} else if (flag == 'f') {
11981198
return false;
1199+
} else if (rtk && bin == HA_BIN_GREP && flag == 'l') {
1200+
return false;
11991201
} else if (strchr(val_flags, flag)) {
12001202
if (*f) {
12011203
f += strlen(f);

‎tests/test_cli.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8833,10 +8833,9 @@ TEST(cli_hook_augment_bash_pattern_extractor) {
88338833
"env FOO=bar rg CreateStripeCheckout .", out, sizeof(out)));
88348834
ASSERT_STR_EQ(out, "CreateStripeCheckout");
88358835

8836-
/* rtk -l <N> consumes N and still finds the pattern */
8837-
ASSERT_TRUE(cbm_hook_augment_parse_bash_pattern_for_testing(
8836+
/* rtk -l <N> shadows grep's -l with a value-taking form — bail out */
8837+
ASSERT_FALSE(cbm_hook_augment_parse_bash_pattern_for_testing(
88388838
"rtk grep -l 80 CreateStripeCheckout .", out, sizeof(out)));
8839-
ASSERT_STR_EQ(out, "CreateStripeCheckout");
88408839

88418840
/* bail-out cases */
88428841
ASSERT_FALSE(cbm_hook_augment_parse_bash_pattern_for_testing("grep -f /path/patterns .", out,

0 commit comments

Comments
 (0)