From 5aff541fd7a996f7926f06ab0127920a1789203a Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sun, 30 Apr 2023 15:55:59 -0400 Subject: [PATCH] update ed help message to make s commands make more sense --- src/commands/ed.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commands/ed.c b/src/commands/ed.c index 87dd580..ca25de1 100644 --- a/src/commands/ed.c +++ b/src/commands/ed.c @@ -748,6 +748,10 @@ test: fprintf(stderr, "error: invalid number: %s\n", index); break; } + if (matches < 1) { + fprintf(stderr, "error: matches cannot be less than 1\n"); + break; + } } long int sub_len = strlen(replace); long int matches_found = 0; @@ -827,7 +831,9 @@ static void help() { printf("\t\tq\t\tquit file\n"); printf("\t\tQ\t\tquit file unconditionally\n"); printf("\t($)\tr file\t\tread file and append to end of buffer\n"); - printf("\t(.,.)\ts/re/replace/\treplace text at matching regex\n"); + printf("\t(.,.)\ts/re/replace/\treplace the first match on each matching line\n"); + printf("\t(.,.)\ts/re/replace/g\treplace all matches on each matching line\n"); + printf("\t(.,.)\ts/re/replace/n\treplace n matches on each matching line\n"); printf("\t(.,.)\tw file\t\twrite contents of lines to file\n"); printf("\t(.,.)\twq file\t\twrite contents of lines to file then quit\n"); printf("\t(.,.)\tW file\t\tappend contents of line to file\n");