POSIX only specifies the -H, -L, and -P options for use with -R, and
the default is left to the implementation. Without -R, symlinks must
be followed.
Most implementations use -P as the default with -R, which makes sense
to me as default behavior (the source and destination trees are the same).
Since we use the same code for -R and without it, and we allow -H, -L,
and -P without -R, set the default based on the presence of -R. Without
it, use -L as before, as required by POSIX, and with it, use -P to match
the behavior of other implementations.
Since the first column is not padded on the left, all the others will
not be aligned, so the padding isn't very useful.
POSIX says thet output should have the form
"%d %d %d %s\n", <newlines>, <words>, <bytes>, <file>
so just do that.
The previous code was too difficult to decipher for such a simple tool.
Since yes(1) is not specified in any standard and several well-known
implementations only support a single argument, do the same here.
Thanks to everyone who offered implementation suggestions in the
hackers@suckless.org email thread.
Since musl 1.1.23, it too does not provide `major` and `minor` through
sys/types.h, so instead include sys/sysmacros.h based on the absence of
`major` rather than only on glibc.
Thanks to Rich Felker for the suggestion.
A file is executable only if the effective user
have permission to execute it. The real user's
permissions do not matter.
Signed-off-by: Mattias Andrée <maandree@kth.se>
Rather than create the FIFO with incorrect permissions at first, then
restore with chmod(2), just clear the umask when -m is specified, and
pass the parsed mode to mkfifo(2).
On glibc, major, minor, and makedev are all defined in
sys/sysmacros.h with types.h only including this for historical
reasons. A future release of glibc will remove this behaviour,
meaning that major, minor, and makedev will no longer be defined
for us without including sysmacros.h.
POSIX-2017 clarifies that -- and normal option parsing must be supported.
See EXAMPLES in basename(1p).
Signed-off-by: Mattias Andrée <maandree@kth.se>
This expression was wrong, but it was causing a false positive
in some compilers that couldn't see that error() cannot return.
The actual problem of the line is that it was too complex and it is better
to split it in simplex expressions.
Copy was using directly the line numbers and incrementing them
without calling nextln(). It also didn't worry about how
line numbers are modified when we insert new lines.