Although mknod is not a POSIX tool, it is widely available on nearly
all UNIX-like systems. It also can be implemented portably apart
from use of the makedev macros, which is already a requirement of
a couple other tools in sbase.
While we're at it, fix a few bugs:
- Include sys/sysmacros.h if makedev was not defined by sys/types.h
- The default mode should respect the user's umask, rather than
assuming it is 022.
- Clear the umask when -m is specified explicitly so that nodes can
be created with permissions wider than the user's umask.
- Utilize parsemode from libutil to support symbolic mode strings.
Fix "new sentence, new line" warnings throughout so that formatters
can produce correct spacing between sentences.
join.1
Remove unnecessary Ns macros. These are not necessary for delimeters,
which get special treatment.
xinstall.1
Fix date in manual. The contents were last modified on 2016-12-03,
so use that instead of the invalid date.
grep.1
Fix escape sequence for `\<` and `\>`.
ed.1
Remove spurious `\\n` escape for the null-command.
The `tflag || argc > 2` if-statement should only apply when not
creating directories (-d). Otherwise, if we are creating more than
two directories, we get an error if the last argument does not
already exist.
To fix this, move the -d case above and return early.
Instead of clearing the format bits before calling parsemode, leave
them in so we can differentiate between directories and other files,
then clear the format bits in the result.
The fallback useful to provide a consistent order of tied lines, but
in check mode, we don't want it to report disorder for equal lines
(according to the passed flags).
Thanks to Richard Ipsum for the bug report and proposed patch.
Currently, if the delimiter is found after the last field of a keydef,
only up to the beginning of the field is considered. This breaks `sort
-k N,N`, as well as whenever the sorted order comes down to that last
field.
Thanks to Richard Ipsum for the bug report and proposed patch.
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.