提交 e334f873 编写于 作者: A Akira Yokosawa 提交者: Jonathan Corbet

docs: scripts/kernel-doc: Detect absence of FILE arg

Currently, when there is no FILE argument following a switch such
as -man, -rst, or -none, kernel-doc exits with a warning from perl
(long msg folded):

    Use of uninitialized value $ARGV[0] in pattern match (m//)
    at ./scripts/kernel-doc line 438.

, which is unhelpful.

Improve the behavior by adding a check at the bottom of parsing
loop.
If the argument is absent, display help text and exit with
the code of 1 (via usage()).
Signed-off-by: NAkira Yokosawa <akiyks@gmail.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/7b136049-a3ba-0eb5-8717-364d773ff914@gmail.com
[jc: reworked to fix conflict with pod patches]
Signed-off-by: NJonathan Corbet <corbet@lwn.net>
上级 2b306eca
...@@ -352,6 +352,15 @@ while ($ARGV[0] =~ m/^--?(.*)/) { ...@@ -352,6 +352,15 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
-output => \*STDERR, -output => \*STDERR,
); );
} }
if ($#ARGV < 0){
pod2usage(
-message => "FILE argument missing\n",
-exitval => 1,
-verbose => 99,
-sections => 'SYNOPSIS',
-output => \*STDERR,
);
}
} }
# continue execution near EOF; # continue execution near EOF;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册