Commit Graph

1608 Commits

Author SHA1 Message Date
sin
a25a57f6ac tail: Add rudimentary support to detect file truncation
We cannot in general detect that truncation happened.  At the moment
we use a heuristic to compare the file size before and after a write
happened.  If the new file size is smaller than the old, we correctly
handle truncation and dump the entire file to stdout.

If it so happened that the new size is larger or equal to the old size
after the file had been truncated without any reads in between, we will
assume the data was appended to the file.

There is no known way around this other than using inotify or kevent
which is outside the scope of sbase.
2015-02-09 14:47:35 +00:00
FRIGN
ff7093f7b3 An additional size_t-fix in tail(1) 2015-02-09 15:47:08 +01:00
FRIGN
78f33ff069 Convert tail(1) to use size_t 2015-02-09 15:30:23 +01:00
sin
080a1ee833 No need to free the buffer for every call to getline()
It will realloc as necessary if the new line size exceeds the
capacity of the allocated buffer.
2015-02-09 14:11:06 +00:00
FRIGN
2a83c2c8be Add f-flag to tail(1) and refactor code 2015-02-09 15:06:17 +01:00
FRIGN
6b63fc2f2b 2014 -> 2015 in touch.1 2015-02-09 12:38:31 +01:00
sin
8f5d77d8c7 Do not rely on the underlying type of time_t in date(1) and touch(1)
Use LLONG_MAX unconditionally.  In practice this only causes trouble
with systems that are not 2038 ready.
2015-02-08 23:45:03 +00:00
FRIGN
d6b3890af6 Add r-flag to touch(1), refactor manpage and code
and mark it as finished in README.
2015-02-09 00:41:57 +01:00
FRIGN
49ed53b46c Reformat README 2015-02-09 00:20:33 +01:00
FRIGN
1b4ba2b303 Remove wchar.h from unexpand(1)
not needed any more.
2015-02-09 00:20:02 +01:00
FRIGN
1004778757 Update TODO with current roadmap 2015-02-08 23:28:00 +01:00
FRIGN
5699d5fb64 Refactor tar(1) manpage
and mark it as finished in the README.
Specifically, add a small section on the compression flags, which
are basically an infected GNU limb which should be removed from
the face of the earth as soon as possible.
2015-02-08 23:16:27 +01:00
FRIGN
1df65f4af4 Refactor sponge(1) code and manpage
and mark it as finished in README.
2015-02-08 22:17:21 +01:00
FRIGN
8798b8a867 Add arg.h-handling to sync(1) and unlink(1) 2015-02-08 22:13:50 +01:00
FRIGN
3e7c549862 Refactor sync(1) code and manpage
and mark it as finished in README.
2015-02-08 22:08:14 +01:00
FRIGN
e01469c9a2 Refactor unlink(1) code and manpage
Remove superfluous stdlib.h-include.
2015-02-08 21:59:59 +01:00
sin
6397952ab3 Nuke bogus newline 2015-02-08 20:28:18 +00:00
FRIGN
1513c2b766 Refactor unexpand(1) code and manpage, adding tablist support
as already seen for expand(1), only twice as complicated.
2015-02-08 21:24:22 +01:00
FRIGN
28b4b25076 Refactor uname(1) code and manpage
remove stdlib.h-include which was there for no reason and clear
up the manpage.
2015-02-07 22:15:56 +01:00
FRIGN
018d60c6bf Refactor tty(1) code and manpage 2015-02-07 22:00:28 +01:00
FRIGN
352eedff58 No need to check for stdin on fclose()
as we are not trying to read from it afterwards.
2015-02-07 21:42:41 +01:00
FRIGN
cb1b5d532b Handle stdin properly in cmp(1) and remove path comparison
Same paths are undefined behaviour, let's not endorse it.
2015-02-07 21:36:36 +01:00
FRIGN
d756dca999 Reuse 'n' in cmp(1)
Factors out one more local variable.
2015-02-07 21:13:54 +01:00
FRIGN
79e45395e5 Refactor cmp(1) code and manpage
The algorithm had some areas which had potential for improvement.
This should make cmp(1) faster.
There have been changes to behaviour as well:

1) If argv[0] and argv[1] are the same, cmp(1) returns Same.
2) POSIX specifies the format of the difference-message to be:
      "%s %s differ: char %d, line %d\n", file1, file2,
      <byte number>, <line number>
   However, as cmp(1) operates on bytes, not characters, I changed
   it to
      "%s %s differ: byte %d, line %d\n", file1, file2,
      <byte number>, <line number>
   This is one example where the standard just keeps the old format
   for backwards-compatibility. As this is harmful, this change
   makes sense in the sense of consistentcy (and because we take
   the difference of char and byte very seriously in sbase, as
   opposed to GNU coreutils).

The manpage has been annotated, reflecting the second change, and
sections shortened where possible.
Thus I marked cmp(1) as finished in README.
2015-02-07 21:05:33 +01:00
FRIGN
d5d686e9f6 tr : Revert 97c5986146
This was no typo.
2015-02-07 18:09:04 +01:00
sin
39802832af wc: Make output POSIX compliant 2015-02-06 19:46:45 +00:00
sin
0c8fe5d19b wc: Report exit status properly 2015-02-06 19:11:33 +00:00
Hiltjo Posthuma
3b4a366ffd xargs.1: dont justify text, remove " " 2015-02-06 15:43:46 +01:00
Hiltjo Posthuma
e57c3505cc cron.1: path macro for /etc/crontab 2015-02-06 15:43:23 +01:00
Hiltjo Posthuma
97c5986146 tr: small typo 2015-02-06 15:43:07 +01:00
Eon S. Jeon
6b93b14fba support llvm-ar
llvm-ar doesn't understand flags prefixed with dashes.
2015-02-03 10:08:26 +00:00
FRIGN
ff0347e391 Fix tr(1) behaviour in special cases and be stricter about stuff 2015-02-02 19:59:41 +01:00
FRIGN
f9d9672326 Fix segmentation fault in tr(1) with -dc and one set 2015-02-02 17:58:16 +01:00
Jakob Kramer
fdcfbba96c sort: minor manual page adjustments 2015-02-01 21:46:58 +01:00
Hiltjo Posthuma
96fc8383cd man pages: fix some typos 2015-02-01 21:28:17 +01:00
Hiltjo Posthuma
22f4e05b5b man pages: improve consistency 2015-02-01 20:52:28 +01:00
Hiltjo Posthuma
a986e4bbd5 basename: make usage line the same as the man page 2015-02-01 19:26:49 +01:00
Hiltjo Posthuma
d0d852dd42 sort.1: fix warning 2015-02-01 19:02:48 +01:00
Jakob Kramer
331b2729d5 sort manpage: fix key definition 2015-02-01 17:49:02 +00:00
sin
2f6ffc9ec9 No need to specify "rb" and "wb" in fopen, use "r" and "w" 2015-02-01 15:55:30 +00:00
Hiltjo Posthuma
66e1bbccf3 Makefile: stricter regex replace for sbase VERSION 2015-02-01 16:33:46 +01:00
Hiltjo Posthuma
949f930280 split: fixes
- -b argument required, don't allow -b <= 0.
- -l argument required, don't allow -l <= 0.
- usage() and argument parsing: sort flags.
- don't write 0 size file, get rid of goto reproducable with:
  printf 'a' | split -b 1.
- close FILE *in if != stdin.
- mark split as finished in README.
- codestyle fixes.
2015-02-01 16:30:12 +01:00
sin
5552db75ba Don't call var "read" 2015-02-01 10:22:11 +00:00
FRIGN
22f40b5a03 Add explicit boundary to loop in readrune()
You never know what could happen. Better have a "blind" read than
a segmentation fault.
2015-02-01 04:20:02 +01:00
FRIGN
986a9de51a Add even stricter UTF-8-support to wc(1)
using readrune() and iswspace().
musl for instance doesn't differentiate between iswspace() and
isspace(), but when it does, the code will be ready.
It goes without saying that GNU coreutils don't use iswspace()[0].

[0]: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/wc.c
2015-02-01 04:06:06 +01:00
FRIGN
696bb992c3 Return number of bytes read even on a partial read
and set the rune to Runeerror for later checking (if desired).
2015-02-01 03:54:56 +01:00
FRIGN
f2e6af7350 Return number of bytes read in readrune()
Could be useful in some cases...
2015-02-01 03:43:54 +01:00
FRIGN
8ab096d2a4 Finish up wc(1)
Use size_t for all counts, fix the manpage and refactor the code.
Here's yet another place where GNU coreutils fail:

sbase:
$ echo "GNU/Turd sucks" | wc -cm
    15

coreutils:
$ echo "GNU/Turd sucks" | wc -cm
     15      15

Take a bloody guess which behaviour is correct[0].

[0]: http://pubs.opengroup.org/onlinepubs/009604499/utilities/wc.html
2015-02-01 03:01:11 +01:00
sin
d75cc2e556 POSIX doesn't specify yes(1) so mark it as such in README 2015-02-01 01:27:44 +00:00
sin
9b37332e1e yes: Minor style fix 2015-02-01 01:27:05 +00:00