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>
This reverts commit 9016d288f1cd03bf514fe84d537b203040e1ccf8.
Tools that have no options are required by POSIX to support "--" so
that conforming applications have a way to shield their operands from
implementations that provide options as an extension.
echo(1) is just an exception, so it is handled specially.
See OPTIONS in https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap01.html#tag_17_04
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.
Current handling of strings is a bit messy. This type is copied
from the sed implementation. Addchar_ is added to be able to live
with String and old style chars based in 3 different variables.