From 3b18aeb8bdba4bcc7eb942e39c542778d1cffbfa Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 6 Oct 2025 14:41:14 +0200 Subject: [PATCH] managen: verify the options used in example lines Also fix the --knownhosts typo Follow-up to aae18c4bdc1a3bf5 Reported-by: Daniel Terhorst-North URL: https://mas.to/@tastapod/115327102344617386 Closes #18884 --- docs/cmdline-opts/knownhosts.md | 2 +- scripts/managen | 23 +++++++++++++++++++++++ tests/data/test1705 | 4 ++-- tests/data/test1706 | 4 ++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/cmdline-opts/knownhosts.md b/docs/cmdline-opts/knownhosts.md index 47095632df..4b6386dd24 100644 --- a/docs/cmdline-opts/knownhosts.md +++ b/docs/cmdline-opts/knownhosts.md @@ -14,7 +14,7 @@ See-also: - insecure - key Example: - - --knownhost filename --key here $URL + - --knownhosts filename --key here $URL --- # `--knownhosts` diff --git a/scripts/managen b/scripts/managen index 17c8677882..0c75148fd1 100755 --- a/scripts/managen +++ b/scripts/managen @@ -880,6 +880,29 @@ sub single { if($examples[0]) { my $s =""; $s="s" if($examples[1]); + foreach my $e (@examples) { + my $check = $e; + # verify the used options + for my $e (split(/ /, $check)) { + if($e =~ /^-([^- ])/) { + my $opt = $1; + if(!$optshort{$opt}) { + print STDERR "$f:$line:1:ERROR: unknown option in ". + "example: -$opt\n"; + return 2; + } + } + elsif($e =~ /^--([^ =]*)/) { + my $opt = $1; + $opt =~ s/^expand-//g; + if(!$helplong{$opt}) { + print STDERR "$f:$line:1:ERROR: unknown option in ". + "example: '--$opt'\n"; + return 2; + } + } + } + } if($manpage) { print "\nExample$s:\n"; print ".nf\n"; diff --git a/tests/data/test1705 b/tests/data/test1705 index 7c21ffa349..26ddf3d4ad 100644 --- a/tests/data/test1705 +++ b/tests/data/test1705 @@ -52,7 +52,7 @@ See-also: - trace - trace-ascii Example: - - --verbose $URL + - --fakeitreal $URL --- # `--verbose` @@ -231,7 +231,7 @@ Disable it again with \-\-no-fakeitreal. Example: .nf -curl --verbose https://example.com +curl --fakeitreal https://example.com .fi This option is mutually exclusive with \fI\-\-trace\fP and \fI\-\-trace\-ascii\fP. diff --git a/tests/data/test1706 b/tests/data/test1706 index 6362678e9a..f821618d27 100644 --- a/tests/data/test1706 +++ b/tests/data/test1706 @@ -52,7 +52,7 @@ See-also: - trace - trace-ascii Example: - - --verbose $URL + - --fakeitreal $URL --- # `--verbose` @@ -196,7 +196,7 @@ DESCRIPTION effect. Disable it again with --no-fakeitreal. Example: - curl --verbose https://example.com + curl --fakeitreal https://example.com This option is mutually exclusive with --trace and --trace-ascii. See also --include, --silent, --trace and --trace-ascii. -- 2.47.3