Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-29 Thread Klemens Nanni

On Sat, Oct 29, 2016 at 08:42:12PM +0200, Laslo Hunhold wrote:

On Fri, 28 Oct 2016 14:40:01 +0200
Klemens Nanni  wrote:


Returning -1 upon a valid invocation like 'dwm -v' is just wrong.


I agree, but we should get rid of this EXIT_* stuff altogether.
My proposal:

if (argc == 2 && !strcmp("-v", argv[1])) {
fputs("dwm-"VERSION, stdout);
return 0;
} else if (argc != 1)
die("usage: dwm [-v]");

What do you guys think about it?


I'm used to seeing/printing version information on stderr as it's more
of a debug information than normal output.

EXIT_* aren't really needed imho either.



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-29 Thread Quentin Rameau
> I agree, but we should get rid of this EXIT_* stuff altogether.
> My proposal:
> 
>   if (argc == 2 && !strcmp("-v", argv[1])) {
>   fputs("dwm-"VERSION, stdout);
>   return 0;
>   } else if (argc != 1)
>   die("usage: dwm [-v]");
> 
> What do you guys think about it?
I think you should use “puts("dwm-"VERSION);” ;p



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-29 Thread Laslo Hunhold
On Fri, 28 Oct 2016 14:40:01 +0200
Klemens Nanni  wrote:

> Returning -1 upon a valid invocation like 'dwm -v' is just wrong.

I agree, but we should get rid of this EXIT_* stuff altogether.
My proposal:

if (argc == 2 && !strcmp("-v", argv[1])) {
fputs("dwm-"VERSION, stdout);
return 0;
} else if (argc != 1)
die("usage: dwm [-v]");

What do you guys think about it?

Cheers

Laslo

-- 
Laslo Hunhold 



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread David Phillips
On Fri, Oct 28, 2016 at 03:58:14PM +0200, Martin Kühne wrote:
> IMHO, when failing to parse command line arguments, usage() should be
> called before exiting with EXIT_FAILURE.
> on invocation with -h|--help, it should exit with EXIT_SUCCESS.
> 
> cheers!
> mar77i

This sounds sane and solves the problems from both sides of the camp.



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Martin Kühne
IMHO, when failing to parse command line arguments, usage() should be
called before exiting with EXIT_FAILURE.
on invocation with -h|--help, it should exit with EXIT_SUCCESS.

cheers!
mar77i



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread quinq
> > If not, that's your fault (or the packager you trust do to it for
> > you, actually again your responsability).  
> 
> Blaming someone else won't solve the issue.
Exactly, hence “your responsability”.



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Ali H. Fardan

On 2016-10-28 13:21, Quentin Rameau wrote:

On 2016-10-28 13:02, Quentin Rameau wrote:
> On Fri, Oct 28, 2016 at 12:45:14PM +, Ali H. Fardan wrote:
>> actually, imo, I think
>> usage() should return success.
> Surely not.
> The call to usage() is made when wrong options have been passed to
> the tool, you wouldn't return “no error” code when there actually
> has been an error.

How could a script test if 'foo' is compiled correctly and runs
without any missing shared libraries? if such a thing existed it will
return 1> else, 0 is returned, the program still works fine, you just
didn't give it the right arguments.

You're clearly on the wrong path for what you want to test here.

A script wouldn't test on runtime if there has been some compile-time
errors.

That's not for the tool to tell you if it has been correctly built or
not, its behaviour is expected to be built correctly.
If not, that's your fault (or the packager you trust do to it for you,
actually again your responsability).


Blaming someone else won't solve the issue.

---
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Quentin Rameau
> On 2016-10-28 13:02, Quentin Rameau wrote:
> > On Fri, Oct 28, 2016 at 12:45:14PM +, Ali H. Fardan wrote:  
> >> actually, imo, I think
> >> usage() should return success.  
> > Surely not.
> > The call to usage() is made when wrong options have been passed to
> > the tool, you wouldn't return “no error” code when there actually
> > has been an error.  
> 
> How could a script test if 'foo' is compiled correctly and runs
> without any missing shared libraries? if such a thing existed it will
> return 1> else, 0 is returned, the program still works fine, you just
> didn't give it the right arguments.
You're clearly on the wrong path for what you want to test here.

A script wouldn't test on runtime if there has been some compile-time
errors.

That's not for the tool to tell you if it has been correctly built or
not, its behaviour is expected to be built correctly.
If not, that's your fault (or the packager you trust do to it for you,
actually again your responsability).



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Ali H. Fardan

On 2016-10-28 13:02, Quentin Rameau wrote:

On Fri, Oct 28, 2016 at 12:45:14PM +, Ali H. Fardan wrote:

actually, imo, I think
usage() should return success.

Surely not.
The call to usage() is made when wrong options have been passed to the
tool, you wouldn't return “no error” code when there actually has been
an error.


How could a script test if 'foo' is compiled correctly and runs without
any missing shared libraries? if such a thing existed it will return 1>
else, 0 is returned, the program still works fine, you just didn't give
it the right arguments.

---
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments



Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Ali H. Fardan

I don't think -v should output to stderr either, actually, imo, I think
usage() should return success.

On 2016-10-28 12:40, Klemens Nanni wrote:

Returning -1 upon a valid invocation like 'dwm -v' is just wrong.
---
 dwm.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dwm.c b/dwm.c
index 421bf27..35828b4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -2122,8 +2122,10 @@ zoom(const Arg *arg)
 int
 main(int argc, char *argv[])
 {
-   if (argc == 2 && !strcmp("-v", argv[1]))
-   die("dwm-"VERSION);
+   if (argc == 2 && !strcmp("-v", argv[1])) {
+   fputs("dwm-"VERSION, stderr);
+   return EXIT_SUCCESS;
+   }
else if (argc != 1)
die("usage: dwm [-v]");
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())


---
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments