aboutsummaryrefslogtreecommitdiff
path: root/bp.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-06-23 13:09:39 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-06-23 13:09:39 -0400
commitfaba716e87b6201784fa71542e76073ca25963e8 (patch)
treed4708351258cf15fbbbbcb22c7b902f70518561e /bp.c
parent22015bf6ac80585aec0679d443822213b1b4dd4c (diff)
Add special case support for parsing `bp "->foo"` as a pattern instead
of an invalid flag
Diffstat (limited to 'bp.c')
-rw-r--r--bp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bp.c b/bp.c
index 8d8ade8..bb887ff 100644
--- a/bp.c
+++ b/bp.c
@@ -647,9 +647,9 @@ int main(int argc, char *argv[])
options.print_filenames = 0;
} else if (!streq(flag, "auto"))
errx(EXIT_FAILURE, "Unknown --format option: %s", flag);
- } else if (argv[0][0] == '-' && argv[0][1] && argv[0][1] != '-') { // single-char flags
- errx(EXIT_FAILURE, "Unrecognized flag: -%c\n\n%s", argv[0][1], usage);
- } else if (argv[0][0] != '-') {
+ } else if (argv[0][0] != '-' || strncmp(argv[0], "->", 2) == 0) {
+ // As a special case, support `bp '->foo'` as a way to search for
+ // pointer field accesses without needing to escape anything.
if (pattern != NULL) break;
bp_pat_t *p = assert_pat(argv[0], NULL, bp_stringpattern(argv[0], argv[0]+strlen(argv[0])));
if (!explicit_case_sensitivity)