Commit Graph

15 Commits

Author SHA1 Message Date
FRIGN 9016d288f1 Do not use arg.h for tools which take no flags
We've already seen the issue with echo(1): Before we changed it to
ignore "--", the command

$ echo --

did not work as expected. Given POSIX mandated this and makes most
sense, in the interest of consistency the other tools need to be
streamlined for that as well.
Looking at yes(1) for instance, there's no reason to skip "--" in
the argument list.
We do not have long options like GNU does and there's no reason to
tinker with that here.

The majority of tools changed are ones taking lists of arguments
or only a single one. There's no reason why dirname should "fail"
on "--". In the end, this is a valid name.

The practice of hand-holding the user was established with the GNU
coreutils. "--help" and "--version" long-options are a disgrace to
what could've been done properly with manpages.
2015-04-25 11:43:14 +01:00
FRIGN 286df29e7d Make already audited tools argv-centric instead of argc-centric
This has already been suggested by Evan Gates <evan.gates@gmail.com>
and he's totally right about it.
So, what's the problem?
I wrote a testing program asshole.c with

int
main(void)
{
        execl("/path/to/sbase/echo", "echo", "test");
        return 0;
}

and checked the results with glibc and musl. Note that the
sentinel NULL is missing from the end of the argument list.
glibc calculates an argc of 5, musl 4 (instead of 2) and thus
mess up things anyway.
The powerful arg.h also focuses on argv instead of argc as well,
but ignoring argc completely is also the wrong way to go.
Instead, a more idiomatic approach is to check *argv only and
decrement argc on the go.
While at it, I rewrote yes(1) in an argv-centric way as well.

All audited tools have been "fixed" and each following audited
tool will receive the same treatment.
2015-03-02 14:19:26 +01:00
FRIGN ad9a9dd3e1 Audit yes(1)
Oh well, time to simplify the loop.
Also, change the comment on unreachable code to something more clear.
2015-02-28 21:11:10 +01:00
FRIGN 31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
sin 9b37332e1e yes: Minor style fix 2015-02-01 01:27:05 +00:00
FRIGN 0b5ab80b05 Fix potential modulo 0 2015-02-01 02:23:35 +01:00
FRIGN f40608ef09 Finish up yes(1) by adding multiple string support 2015-02-01 02:13:47 +01:00
FRIGN eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
sin 0c5b7b9155 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:46:59 +01:00
Hiltjo Posthuma 953ebf3573 code style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:30 +01:00
dwts 459161481a use always static for usage and keep usage definition above main 2014-04-22 14:49:23 +01:00
sin a8ef54bae1 Simplify yes(1)
Just pick the first argument if multiple are provided.
2013-10-05 15:11:16 +01:00
Connor Lane Smith fcb8821246 revert to per-cmd usage() 2012-05-15 13:32:56 +01:00
Connor Lane Smith 146cca114e new ARGBEGIN & usage() function 2012-05-14 21:28:41 +01:00
Christoph Lohmann 120d817920 Adding the yes(1) command. 2012-04-23 16:27:40 +02:00