mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-29 11:35:47 +01:00
getstyle: Fix output to stdout
There is a problem with getstyle invoked with no arguments:
[mafra@Pilar:util]$ ./getstyle
Usage: getstyle [-t] [-p] [-h] [-v] [file]
or with -t:
[mafra@Pilar:util]$ ./getstyle -t
Usage: getstyle [-t] [-p] [-h] [-v] [file]
In both cases it is supposed to write to the standard output:
[mafra@Pilar:wmaker.git]$ getstyle -h
Usage: getstyle [-t] [-p] [-h] [-v] [file]
Retrieves style/theme configuration and output to FILE or to stdout
This regression was caused by commit 6bf7994520 ("style Stuff up").
When that commit did
argc -= optind;
if (argc != 1)
print_help(0,1);
it excluded the output to stdout as valid, because in this case
argc - optind is zero (see the manpage of getopt(3)).
The correct handling is to set the style_file only when there is
one non-option ARGV-element (argc - optind == 1) and print the
help message when there are more than one non-option element.
This commit is contained in:
@@ -385,17 +385,18 @@ int main(int argc, char **argv)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
argc -= optind;
|
/* At most one non-option ARGV-element is accepted (the theme name) */
|
||||||
argv += optind;
|
if (argc - optind > 1)
|
||||||
|
|
||||||
if (argc != 1)
|
|
||||||
print_help(0, 1);
|
print_help(0, 1);
|
||||||
|
|
||||||
style_file = argv[0];
|
if (argc - optind == 1) {
|
||||||
while ((p = strchr(style_file, '/')) != NULL)
|
style_file = argv[argc - 1];
|
||||||
*p = '_';
|
while ((p = strchr(style_file, '/')) != NULL)
|
||||||
|
*p = '_';
|
||||||
|
}
|
||||||
|
|
||||||
if (style_file && !make_pack) /* what's this? */
|
/* A theme name was given but the option to create it (-p) was not */
|
||||||
|
if (style_file && !make_pack)
|
||||||
print_help(0, 1);
|
print_help(0, 1);
|
||||||
|
|
||||||
if (make_pack && !style_file) {
|
if (make_pack && !style_file) {
|
||||||
|
|||||||
Reference in New Issue
Block a user