Commit Graph

1466 Commits

Author SHA1 Message Date
Dionysis Grigoropoulos
2d6cde1862 humansize: Use uintmax_t for size
du(1) breaks on 32-bit size_t for files greater than 4G.
2015-04-28 11:36:58 +01:00
sin
68fb6754ba which: Add LICENSE header 2015-04-27 19:33:57 +01:00
FRIGN
0b76449414 Add flag support to printf(1)
We skipped flags before, so no real bug, but it's trivial to add
now, so there's no reason not to do it.
2015-04-27 19:33:57 +01:00
FRIGN
b333176b8c Refactor and audit which(1)
Use the *at functions instead of building paths manually. We do
still have path-building in recurse() and other areas, but the
long-term goal is to rid most interfaces of that for practical
and security reasons.
In this case, it's more or less trivial.

Also, refactor the manpage to be more consistent with the others.

BUGFIX: Return exit status 3 on error.
2015-04-27 19:33:57 +01:00
Michael Forney
035e14c516 tr: Fix -c option when translating 2015-04-27 17:16:37 +01:00
Hiltjo Posthuma
e34bcca3e3 join: remove argv0, it is in arg.h 2015-04-27 16:58:42 +01:00
Hiltjo Posthuma
58cb564bbd add which 2015-04-27 16:58:42 +01:00
FRIGN
5595af5742 Convert humansize() to accept a size_t instead of a double
General convention is to use size_t to store sizes of all kinds.
Internally, the function uses double anyway, but at least this
doesn't clobber up the API any more and there's a chance in the
future to make this function a bit cleaner and not use this dirty
static buffer hack any more.
2015-04-25 11:43:14 +01:00
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
Hiltjo Posthuma
e73f58937d du: staticize du 2015-04-25 11:43:14 +01:00
FRIGN
5a52154a47 tar: Fix remove(3)-error-message 2015-04-24 10:09:26 +01:00
sin
fbd39af1fa tar: Minor style fixes 2015-04-24 10:09:25 +01:00
sin
ac694e6c4a tar: Add routine to test if the tar archive is "legit" 2015-04-23 16:34:12 +01:00
sin
74f680948e tar: Rename field to better match spec 2015-04-23 16:34:12 +01:00
sin
624bf64ac5 tar: Use more conventional name for iterator 2015-04-23 16:34:12 +01:00
sin
76eb6bdf42 tar: Match type like everywhere else 2015-04-23 15:32:00 +01:00
sin
d1e19e972a tar: No need to zero-fill variables with global storage 2015-04-23 15:32:00 +01:00
sin
ab267a87eb tar: Use raw I/O instead of standard file streams
As part of refactoring tar to add support for compression through
gzip/bzip2, it makes sense to avoid intermixing file stream I/O with
raw I/O.
2015-04-23 15:32:00 +01:00
sin
fb1595a69c tar: Use remove() instead of unlink() so we can work on directories too 2015-04-23 15:32:00 +01:00
sin
3419f94d83 tar: Staticise symbols 2015-04-23 12:38:53 +01:00
sin
ce4a10abe7 tar: Apply mtime at the end otherwise it gets reverted
Consider the following scenario:

1) create a/
2) apply mtime to a/
3) create a/b # reverts mtime on a

TODO: utimes() does not work on symlinks.
2015-04-23 12:37:39 +01:00
sin
aab2e273bd tar: Add skipblk() and simplify code 2015-04-23 12:37:38 +01:00
sin
201e71be2b tar: Skip over git's global pax header crap 2015-04-23 00:05:23 +01:00
sin
7a0d9fb3ea tar: Skip over data before processing the next entry
When we selectively process entries from the archive, ensure that
we jump over the data section of each uninteresting entry before going
on to process the next entry.  Not doing so, leaves the file stream
pointer in the wrong place.
2015-04-22 23:24:39 +01:00
sin
2fc73e410c xargs: Don't print trailing spaces when -t is set 2015-04-21 18:00:48 +01:00
sin
10b57e8a3d Actually print <space> to stream in putword() too 2015-04-21 18:00:47 +01:00
sin
c914a2feca Update putword() to accept a FILE * 2015-04-21 18:00:47 +01:00
sin
504855ff96 expr: Don't interpret any arguments
expr -1 '<' 1 failed previously.

There is no need to have usage at all, any errors will be flagged
up as necessary further down.
2015-04-21 17:09:20 +01:00
sin
0925bf95ac tar: Cast to proper type, no functional change 2015-04-21 16:20:31 +01:00
sin
22c0ae67a4 tar: Don't error out if we can't pull pw/gr entries 2015-04-21 16:18:46 +01:00
sin
e6c532a47a tar: Briefly update manpage and usage for the latest changes 2015-04-21 15:43:52 +01:00
sin
258d0793ac tar: Allow extracting only a given list of files
tar -xf foo.tar a b c
2015-04-21 15:43:52 +01:00
sin
fde9e29d05 tar: Don't assume that name, linkname and prefix are null-terminated 2015-04-21 15:43:52 +01:00
sin
f1261b57d9 Add support to tar multiple files in a single run 2015-04-21 15:43:52 +01:00
sin
542f645bc2 Convert chown() failure to a warning in tar(1)
This particular change does not have any immediate shortcomings.
We still print a warning to alert the user.

Exiting on a chown() failure caused problems when untarring
inside a restricted user namespace on Linux where the uid/gid
mappings were limited.
2015-04-21 09:17:26 +01:00
Hiltjo Posthuma
ce145a39a7 expr: fix, first parse then enfshut 2015-04-21 09:11:36 +01:00
FRIGN
7be2449aa9 tr(1): Show an error when classes and non-classes are mixed 2015-04-20 20:41:11 +01:00
Hiltjo Posthuma
bfcf46ac5e tr: fix "isdigit" check 2015-04-20 20:41:11 +01:00
sin
b9d60bee87 Move mkdirp() to libutil 2015-04-20 18:04:08 +01:00
sin
31af8555a7 Add LICENSE header to fshut.c 2015-04-20 18:04:08 +01:00
sin
6e30efb9bb Fix mkdir -p with a leading / 2015-04-20 17:47:14 +01:00
Hiltjo Posthuma
9c03736696 tar: error if strdup fails (estrdup) 2015-04-20 17:32:54 +01:00
sin
71eeb21feb Use strtol() instead of strtoul() in tar(1) 2015-04-20 16:36:03 +01:00
sin
97905f6991 Fix tar(1) handling of archives with improper internal order
Not all archives are packed in such way to be generated without
having to recursively generate the output path.

For now, reuse the function from mkdir.c and later move it to
libutil.
2015-04-20 16:36:03 +01:00
sin
3ef6d4e4c9 Fix tar(1) handling of <space> terminated fields
Numeric fields can be <space> terminated.  Ensure those are
patched with NULs so we can perform string operations.

There is more work to be done in this area, namely some fields like
name, linkname and prefix are not always null-terminated.
2015-04-20 16:36:03 +01:00
sin
d6885987e5 Fix mkdir -p and allow -m to be specified along with -p
The mkdirp() function would not create the entire path but it just
happened to work because of the extra mkdir in the main loop.
2015-04-20 16:36:02 +01:00
sin
684b6fe8f2 Enable -lrt by default 2015-04-20 11:44:20 +01:00
sin
d412dad470 Simplify condition in wc(1) 2015-04-20 11:26:38 +01:00
Wolfgang Corcoran-Mathe
cd0b771cbb Add join(1) 2015-04-20 11:24:12 +01:00
FRIGN
f83d7bc647 Add SILENT flag to recurse()
recurse() is getting smarter every day. I expect it to pass the Turing
test in a few months.
Along the way, it was reported that "rm -f" on nonexistant files reports
their missing as an internal recurse()-error.
So recurse() knows when to shut up, I added the SILENT flag to fix all
these things.
2015-04-20 11:12:40 +01:00