Commit Graph

195 Commits

Author SHA1 Message Date
FRIGN
7bacd98b0e Audit wc(1)
Style cleanup, Manpage refactoring.
2015-03-18 00:20:19 +01:00
FRIGN
a20a9350db Audit uuencode(1)
Style cleanup, Manpage refactoring.
2015-03-18 00:14:56 +01:00
FRIGN
1b71559431 Audit uudecode(1)
Style cleanup, Manpage refactoring.
2015-03-18 00:10:36 +01:00
FRIGN
4af8889396 Audit uniq(1)
Refactor the manpage and small style-changes in uniq.c.
Remove unnecessary "else", we catch argc > 2 earlier already.
2015-03-17 23:59:09 +01:00
FRIGN
5af4cdcd60 Audit unexpand(1)
I checked the algorithm already a while ago. What was left was a
couple of style-fixes.
2015-03-17 23:45:03 +01:00
FRIGN
f6dc69eca3 Audit tr(1)
A tool of my own devising, except from a small style-fix this code
has already been triple-checked.
2015-03-17 23:41:22 +01:00
FRIGN
95fb7364a8 Audit touch(1)
Only minor things, as I already worked heavily on this tool a while
ago.
Fix style in the main loop and wording in the manpage.
2015-03-17 23:38:09 +01:00
FRIGN
99ded174b2 Audit test(1)
Only add empty lines before returns, everything else is ok.
Also add the STANDARDS-section to the manpage, which was only
present as a heading until now.
2015-03-17 23:35:11 +01:00
FRIGN
6372a8f227 Audit tail(1)
1) Specify default in manpage under flag.
2) Boolean and return value style fixes.
3) argv-argc-centric loop.
4) No need to check for argc == 1 before the fflag-subroutine.
5) Remove indentation.
6) Empty line before return.
2015-03-17 23:24:43 +01:00
FRIGN
3c5d0ce4ca Mark sync(1) as audited
Nothing to be done here.
2015-03-17 23:07:41 +01:00
FRIGN
32b9d76747 Audit strings(1)
Only smaller style-changes. I already refactored the underlying
logic a while ago.
2015-03-17 23:05:50 +01:00
FRIGN
3725d501b3 Audit split(1)
1) Refactor manpage, add STANDARDS section.
2) Boolean-style-changes.
3) Update usage, reflecting num-idiom also changed in the manpage.
4) Refactor error messages.
5) Also fclose stdin.
6) Empty line before return.
2015-03-17 22:59:48 +01:00
FRIGN
c7deb4f2b7 Audit printf(1)
Not a lot to do here, I wrote this less than a month ago. The only
thing I missed was the newline before return.
2015-03-17 21:43:01 +01:00
FRIGN
1bc002b44a Audit paste(1)
Well, basically there was not a lot to do, as I already (fortunately)
audited this code a while back.
There were only minor style-changes.
2015-03-17 21:34:38 +01:00
FRIGN
a76d4943b5 Audit mktemp(1)
1) Unglobalize variables.
2) Sort local variables.
3) Use return instead of exit() in main().
4) Add empty line before return.
2015-03-17 11:01:33 +01:00
FRIGN
683d108387 Audit logname(1)
1) Add usage().
2) Idiomatic argv0-setter. We don't use arg.h, as we do not process
   flags or arguments.
3) Remove program-name from eprintf-call. This is done in the eprintf-
   function itself when the DEBUG-define is set.
   We'll activate it by default later.
4) Add empty line before return.
2015-03-17 00:44:18 +01:00
FRIGN
64da0d1ebc Audit kill(1)
1) Refactor the manpage with num-options, optimize wording to be more
   concise and to the point, pid also specifies process groups.
2) Make int sig const.
3) Remove prototypes.
4) /* not reached */ consistency.
5) Refactor usage() with eprintf.
6) Refactor arg-parser with a switch, use estrtonum
7) Use return instead of exit() in main()
8) argc-argv-correctness.
2015-03-16 12:37:46 +01:00
FRIGN
942c3613bc Audit fold(1)
1) Use num-wording in the manpage, remove offensive remark against
   the beloved -num-syntax <3.
2) Style changes.
3) Report errors of getline.
4) argv-argc-centric argument loop.
5) Rename r to ret for consistency.
2015-03-13 23:50:09 +01:00
FRIGN
b12041365d Audit expand(1)
Not much to do here. Forgot a colon in the manpage and some style-
changes in the code.
2015-03-13 00:38:29 +01:00
FRIGN
c4e0080bbf Mark du(1) as audited in README 2015-03-11 23:31:26 +01:00
FRIGN
00ca97b279 Mark cut(1) and cron(1) as audited in README
I finished auditing cut(1) a few minutes ago, and cron(1) is an
upstream project which needs to be taken care of upstream (sin's call).
2015-03-11 17:33:08 +01:00
FRIGN
f1a1b7f994 Mark comm(1) as audited in README 2015-03-11 13:47:33 +01:00
FRIGN
695153ac18 Audit cmp(1)
1) Remove the return-value-enum, which is not necessary for a simple
   program like this.
2) Don't disallow both l and s to be specified. This is undefined
   behaviour defined by POSIX, so we don't start demanding things
   from the user.
3) Replace exit() with return (we are in main).
4) Refactor main loop to never return in the loop, but actually
   set the same-value and break, which increases readability.
5) Remove the final fclose()'s. The OS will take care of them, no
   need to become cleansy here.
6) Use idiomatic return-value using same. This concludes the
   increase of readability in the main-loop.
2015-03-11 11:16:40 +01:00
FRIGN
d6818a3c5f Audit cksum(1)
1) Reorder local variables.
2) Cleanup error messages, use %zu for size_t.
3) combine putchar(' ') and fputs to substitute printf(" %s", s).
4) Fix usage().
5) argv-argc-usage-fix.
6) Add empty line before return.
2015-03-11 00:13:48 +01:00
Quentin Rameau
82bebf8ce7 nl: add -l option 2015-03-10 12:55:06 +00:00
FRIGN
3a04302c66 Audit chown(1)
Similar to the chgrp(1)-audit:
1) Refactor manpage so it's actually fun to read
2) BUGFIX: Call (l)chown properly when the H-flag is specified
   (only when depth > 0)
3) BUGFIX: Call (l)chown properly when the h-flag is specified
   (only when depth = 0).
4) BUGFIX: Only recurse() in chgrp() when the initial chownf()
   succeeds.
5) Style fixes, argv-basing.
6) Rename status to ret for consistency.
7) Add blank line before return.
2015-03-09 00:42:23 +01:00
FRIGN
fba669da88 Audit chgrp(1)
1) Refactor manpage so it's actually fun to read.
2) BUGFIX: Call (l)chown properly when the H-flag is specified
   (only when depth > 0).
3) BUGFIX: Call (l)chown properly when the h-flag is specified
   (only when depth = 0).
4) BUGFIX: Only recurse() in chgrp() when the initial chownf()
   succeeds.
5) Style fixes, argv-basing.
6) Rename status to ret for consistency.
7) Add blank line before return.
2015-03-08 23:31:59 +01:00
FRIGN
76ad86b2a3 Audit cal(1)
1) Update manpage with the num-syntax.
2) Use size_t for years and derivatives.
3) Use putchar instead of printf wherever possible.
4) Update usage().
5) Style changes.
2015-03-08 21:28:32 +01:00
FRIGN
f140403fca Audit cols(1)
1) Refactor manpage.
2) De-globalize local values.
3) update usage().
4) sort local variable declarations.
5) fix wrong argument in strtonum (3 -> 1).
6) argc-argv style, boolean style.
7) check bytes > 0 before accessing b.lines[i][bytes - 1]
   relying on len only makes sense but let's not push it.
7) don't break on maxlen > (chars - 1) / 2. This didn't even
   make sense.
8) _correctly_ calculate cols and rows in a readable way.
9) Rewrite loop over rows and cols in a readable way and
   using putchar in a loop instead of printf-magic or fputs
   where not necessary.
2015-03-08 19:49:59 +01:00
FRIGN
0c2f19c210 Audit logger(1)
1) Update manpage to current style
2) Line spacing
3) Local variable grouping
4) check for getline >= 0 instead of != -1
5) error message cleanup
2015-03-07 00:10:22 +01:00
FRIGN
ab26b5583e Audit ln(1)
1) Clarify behaviour when the f-flag is given and a target is in its
   own way.
2) Fix usage()-style.
3) Group local variable declarations.
4) reorder args
5) argc style, other boolean style changes
6) improve error messages
7) set argv[argc - 1] to NULL to allow argv-centric loop later
8) BUGFIX: POSIX specifies that when with the f-flag there's a
   situation where a file stands in its own way for linking it
   should be ignored.
9) Add weprintf() where possible, so we don't pussy out when there's
   a small issue. This is sbase ffs!
2015-03-05 21:14:43 +01:00
FRIGN
aea256c288 Audit chmod(1)
1) Update manpage, refactor the HLP-section and other wordings.
2) BUGFIX: If chmod() fails, don't recurse.
3) Rewrite the arg-loop, fixing several issues:
   BUGFIX: Handle multi-flags (e.g. -RH)
   BUGFIX: Properly handle the termination flag --, error on e.g. --x
   BUGFIX: Error out on an empty flag -.
4) Refactor logic after the arg-loop, which is now simpler thanks
   to argv-incremention.
2015-03-05 19:08:28 +01:00
FRIGN
d9fa4b3ae7 Audit mkdir(1)
1) No need for strchr() in mkdirp or a while-loop. Rewrite it in
   a sane and readable way.
2) fix usage according to the manpage.
3) order includes, don't align local variables.
4) argc-style-fix.
5) BUGFIX: Don't try to chmod() *argv when mkdir() / mkdirp() failed.
6) Add newline before return in two places.
2015-03-05 18:03:08 +01:00
FRIGN
38066de8c2 Audit head(1)
1) Use (s)size_t in head().
2) BUGFIX: only check buf[len - 1] when len > 0, else there would
   be an overflow when getline returns 0 (which can happen) and a
   very potential segmentation fault.
3) fix error-messages.
4) update usage().
5) argv-argc-style.
6) clear up the main loop with if (newline).
7) add newline before return.
2015-03-05 01:01:52 +01:00
FRIGN
68aa324713 Mark uname(1) as audited in README
No changes needed.
2015-03-05 00:33:28 +01:00
FRIGN
6cdae700c9 Mark time(1) as finished and audited in README 2015-03-05 00:29:03 +01:00
FRIGN
109f6b5a60 Audit mv(1)
1) Make argument-naming consistent with other tools (cp(1), ...)
2) style fixes
3) usage() fix
4) BUGFIX: Probably from the old non-arg.h days, the directory-
   check was only done when argc > 3, but with arg.h, this ignores
   the case when 3 arguments were given.
   This is actually a pretty serious issue and I'm glad it's fixed.
5) Moreover, be more verbose when stat() fails and make it clearer
   what the hell is going on at this checkpoint.
2015-03-04 23:22:43 +01:00
FRIGN
aaac1c8800 Audit tee(1)
1) "duplicate" implies that you can only specify two outputs,
   "multiply" is a better word describing the functionality.
2) fix other wording in the manpage
3) fix usage()
4) reorder local variables
5) fix sizeof() style
6) we need argv later, don't increment argv and rather iterate
   over argc.
7) Improve error messages, print the filename which the write
   failed to instead of printing the buffer itself (how much
   sense does that make, printing 1024 Bytes of garbage?).
   Also, give the name of the function which failed.
2015-03-04 23:05:11 +01:00
FRIGN
a6ee96af7c Audit nohup(1)
1) no need to include sys/stat.h
2) remove the enum which just added a layer too thick on this simple
   program
3) argc-style, other style
4) weprintf instead of enprintf, then save the error-message of
   execvp before and return the proper status.
5) write consistent "not reached" comment.
2015-03-04 22:39:12 +01:00
FRIGN
7cb966c170 Audit pwd(1)
Nothing special
1) Update manpage to current style.
2) Reorder functions
3) Logical trickery in getpwd()
2015-03-03 17:24:14 +01:00
Roberto E. Vargas Caballero
443de0a859 Add col command
col is used to display troff documents in ttys, removing the reverse
line feeds generated by .2C in ms. This implementation keeps the limit
of 256 lines of 800 characteres of the original implementation.
2015-03-03 13:35:42 +00:00
FRIGN
274e86e1aa Audit cp(1)
1) Refactor the manpage, which has been a bloody mess, documenting
   fantasy-flags (-d for example) and add a STANDARDS section
2) fix usage()
3) sort ARG-block
4) Check return-value of stat() separately, so a lack of permissions
   doesn't tell the user "the directory doesn't exist", which could
   be a bit confusing.
5) Add empty line before return.
2015-03-02 19:15:19 +01:00
FRIGN
eb137b9e42 Audit chroot(1)
1) Fix usage()
2) Rename *p to *cmd
3) _exit trick with 126 + (savederrno == ENOENT)
4) return-style-fix
2015-03-02 17:46:45 +01:00
FRIGN
520d87e58e Audit mkfifo(1)
1) Fix usage()
2) Group local variables
3) Idiomatic argv-loop
4) BUGFIX: When the m-flag is specified, POSIX clearly says:
   "Set the file permission bits of the newly-created FIFO to the specified mode
   value."
   This means, that if mkfifo() fails for some reason, it should not try to
   chmod() the given path (which has been fixed with the "else if")
   A simple testcase is:

   $ touch testfile; mkfifo -m 000 testfile;

   GNU mkfifo(1): ls -l testfile
   -rw-r--r-- 1 testfile

   sbase mkfifo(1): ls -l testfile
   ---------- 1 testfile
5) Add blank line before return
2015-03-02 17:25:29 +01:00
FRIGN
c01641c897 Audit nice(1)
1) val is sufficient as "int" (read the standard)
2) BUGFIX: If getpriority fails, it returns -1 and sets errno.
   Previously, it would correctly catch the errno but not take
   care of the fact that by then val has been decremented by 1.
   Only change val if the getpriority-call has been successful.
3) Add LIMIT()-macro from st to increase readability.
4) setpriority returns < 0 on failure
5) Remove bikeshedding-comment. Read the standard if you wonder.
6) return-value trick from env(1)
2015-03-02 16:53:13 +01:00
FRIGN
6c3ba4c4c7 Audit rmdir(1)
1) style fix (don't arrange local variables)
2) BUGFIX: Previously, if ret was turned 1 for some folder, it
   would disable the p-flag for every following folders, which
   is not desired.
   Instead, the "else if" makes sure that the p-flag-section is
   only entered when the initial rmdir succeeds.
3) BUGFIX: Previously, the program would cancel with eprintf if
   it failed to remove one folder in the parent-pathname.
   This is not desired, as we have other folders pending.
   Instead, print a warning for the current failing parent-folder,
   set ret to 1 and break off the loop at this point.
   This allows to finish the other pending folders without issues.
2015-03-02 15:39:39 +01:00
FRIGN
e50ee15a9c Audit date(1)
1) Update usage as already done in the manpage
2) group and sort local variable declarations
3) Be pedantic about the number of options. Don't just ignore it
   if argc > 1.
2015-03-02 15:12:19 +01:00
FRIGN
27656a0cbc Audit env(1)
1) Shorten synopsis and reflect this in the manual
2) Use argv0 in usage()
3) Decrement argc in argv-loop for consistency
4) Make it clearer which error-code results from which errno in enprintf
5) Use idiomatic for-loop also for environ. Don't increment these pointers
   in the loop itself!
2015-03-02 14:53:24 +01:00
FRIGN
d806f75cb6 Audit cat(1)
1) Fix usage ... spacing
2) use *argv instead of argv[0] in the idiomatic for-loop
3) Stop the naïve usage of "/dev/fd/0" and use plain stdin
   instead (This also makes error-messages more consistent).
4) Add newline before return
5) Remove comma in manpage
2015-03-02 00:39:26 +01:00
FRIGN
7afc84396a Audit setsid(1)
Nothing special, just a small style-fix.
2015-03-02 00:20:35 +01:00