diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-04-30 15:55:59 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-04-30 15:55:59 -0400 |
commit | 5aff541fd7a996f7926f06ab0127920a1789203a (patch) | |
tree | f82b6d108250c291dd31142f48656f117b4b99dd | |
parent | update help messages and use addressing range for ed s command (diff) | |
download | lazysphere-5aff541fd7a996f7926f06ab0127920a1789203a.tar.gz lazysphere-5aff541fd7a996f7926f06ab0127920a1789203a.tar.bz2 lazysphere-5aff541fd7a996f7926f06ab0127920a1789203a.zip |
update ed help message to make s commands make more sense
-rw-r--r-- | src/commands/ed.c | 8 |
1 files changed, 7 insertions, 1 deletions
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"); |