Commit 64f77f312b15f101bf6c4c65d5359ccc16e3f82b
Committed by
Linus Torvalds
1 parent
f11e9a1534
Exists in
master
and in
20 other branches
scripts/get_maintainer.pl: add ability to read from STDIN
Doesn't need or accept '-' as a trailing option to read stdin. Doesn't print usage() after bad options. Adds --usage as command line equivalent of --help Suggested-by: Borislav Petkov <petkovbb@googlemail.com> Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 15 additions and 11 deletions Side-by-side Diff
scripts/get_maintainer.pl
... | ... | @@ -126,7 +126,7 @@ |
126 | 126 | 'fe|file-emails!' => \$file_emails, |
127 | 127 | 'f|file' => \$from_filename, |
128 | 128 | 'v|version' => \$version, |
129 | - 'h|help' => \$help, | |
129 | + 'h|help|usage' => \$help, | |
130 | 130 | )) { |
131 | 131 | die "$P: invalid argument - use --help if necessary\n"; |
132 | 132 | } |
... | ... | @@ -141,9 +141,9 @@ |
141 | 141 | exit 0; |
142 | 142 | } |
143 | 143 | |
144 | -if ($#ARGV < 0) { | |
145 | - usage(); | |
146 | - die "$P: argument missing: patchfile or -f file please\n"; | |
144 | +if (-t STDIN && !@ARGV) { | |
145 | + # We're talking to a terminal, but have no command line arguments. | |
146 | + die "$P: missing patchfile or -f file - use --help if necessary\n"; | |
147 | 147 | } |
148 | 148 | |
149 | 149 | if ($output_separator ne ", ") { |
... | ... | @@ -165,7 +165,6 @@ |
165 | 165 | } else { |
166 | 166 | my $selections = $email + $scm + $status + $subsystem + $web; |
167 | 167 | if ($selections == 0) { |
168 | - usage(); | |
169 | 168 | die "$P: Missing required option: email, scm, status, subsystem or web\n"; |
170 | 169 | } |
171 | 170 | } |
... | ... | @@ -173,7 +172,6 @@ |
173 | 172 | if ($email && |
174 | 173 | ($email_maintainer + $email_list + $email_subscriber_list + |
175 | 174 | $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { |
176 | - usage(); | |
177 | 175 | die "$P: Please select at least 1 email option\n"; |
178 | 176 | } |
179 | 177 | |
180 | 178 | |
... | ... | @@ -248,12 +246,18 @@ |
248 | 246 | my @keyword_tvi = (); |
249 | 247 | my @file_emails = (); |
250 | 248 | |
249 | +if (!@ARGV) { | |
250 | + push(@ARGV, "&STDIN"); | |
251 | +} | |
252 | + | |
251 | 253 | foreach my $file (@ARGV) { |
252 | - ##if $file is a directory and it lacks a trailing slash, add one | |
253 | - if ((-d $file)) { | |
254 | - $file =~ s@([^/])$@$1/@; | |
255 | - } elsif (!(-f $file)) { | |
256 | - die "$P: file '${file}' not found\n"; | |
254 | + if ($file ne "&STDIN") { | |
255 | + ##if $file is a directory and it lacks a trailing slash, add one | |
256 | + if ((-d $file)) { | |
257 | + $file =~ s@([^/])$@$1/@; | |
258 | + } elsif (!(-f $file)) { | |
259 | + die "$P: file '${file}' not found\n"; | |
260 | + } | |
257 | 261 | } |
258 | 262 | if ($from_filename) { |
259 | 263 | push(@files, $file); |