Commit Graph

1877 Commits

Author SHA1 Message Date
Michael Forney
45b9b26cae libutil/recurse: Remove some unnecessary parentheses 2019-11-02 14:03:10 -07:00
Michael Forney
c5c8c7ff86 libutil/mode: Remove unnecessary octal-to-mode conversion
The values of the file mode macros are specified explicitly by POSIX,
so we can just use the octal value directly.
2019-11-01 19:07:10 -07:00
Michael Forney
b29fc0b05f chgrp: Pass -1 as the owner ID to chown(3)
Otherwise, if the owner ID changes between stat() and chown(), we will
revert to the previous owner while changing the group.
2019-11-01 19:03:00 -07:00
Michael Forney
71ba97c175 chmod: Clear the S_IFMT bits before calling chmod 2019-11-01 01:58:54 -07:00
Michael Forney
4f1d0df755 yes: Simplify, only support one argument
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.
2019-10-31 18:14:18 -07:00
Michael Forney
39f92650d3 ls, tar: Guard inclusion of sys/sysmacros.h by absence of major definition
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.
2019-08-05 14:38:32 -07:00
Mattias Andrée
7315b8686f which: check AT_EACCESS
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>
2019-07-30 07:40:35 -07:00
Mattias Andrée
be34c4a24d which: remove unnecessary third parameter in O_RDONLY call to open(3)
Signed-off-by: Mattias Andrée <maandree@kth.se>
2019-07-29 18:49:14 -07:00
Richard Ipsum
9719a7e3d2 chgrp: parse gid if operand is not group name
[Michael Forney: Removed unnecessary `gid == -1` check, changed *argv
 to argv[0] to match existing code]
2019-07-08 14:07:08 -07:00
Richard Ipsum
dc77c5968b chown/chgrp: chown target not symlink by default
chown on a symlink should only chown the symlink itself when -h
is specified, when no options are provided the target should be chown'd.
2019-07-03 22:33:06 -07:00
Michael Forney
a0fae71977 Don't justify text in README 2019-06-30 13:17:17 -07:00
Michael Forney
adcdc1b308 Move utility status to its own section at the end of README
This way the important information can be found easily at the top.
2019-06-30 13:13:07 -07:00
Michael Forney
d7714c84b5 Remove unnecessary ';' after ARGEND 2019-06-29 18:39:07 -07:00
Michael Forney
d2824f5294 Revert "Do not use arg.h for tools which take no flags"
This reverts commit 9016d288f1.

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
2019-06-29 18:33:48 -07:00
Michael Forney
9ae6c45097 Add .gitignore
Also, add rule to regenerate in case executable list changes.
2019-06-28 00:10:10 -07:00
Michael Forney
01b5105e0c mkfifo: Simplify -m handling
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).
2019-06-13 13:45:37 -07:00
Michael Forney
9a17de569a sed: Print better error message when open fails 2019-06-13 13:08:16 -07:00
Richard Ipsum
2ee4c13433 mkfifo: Set initial mode
From POSIX:

In the symbolic_mode strings, the op characters '+' and '-'
shall be interpreted relative to an assumed initial mode of
a=rw.
2019-06-13 13:07:20 -07:00
Michael Forney
eeedfd87e5 libutil: Rename functions in reserved namespace to prevent potential conflict
libc may define functions with the same names, but differing in prototype.
2019-05-20 16:56:07 -07:00
Richard Ipsum
036449cdf1 grep: Fix exit status on use of -l 2019-05-20 12:38:54 -07:00
Richard Ipsum
5b92551057 cal: Centre month and year above calendar 2019-04-28 14:10:38 -07:00
Richard Ipsum
aae808fe5b cal: Fix grid alignment for years < 1000 2019-04-22 19:08:17 -07:00
Michael Forney
ef9f6f359a expr: Allocate arrays with reallocarray instead of VLA
The length of these arrays is user input, and this is the only use of
VLAs in sbase.
2019-04-16 17:44:08 -07:00
Michael Forney
3fec3e2f4c libutil: Add enreallocarray 2019-04-16 17:41:39 -07:00
Michael Forney
5d49332d4f libutf: Adjust runelen prototype to match definition
The `const` isn't useful here.
2019-04-16 17:27:38 -07:00
Richard Ipsum
09c2311b3a date: Fix default format string
From POSIX:

When no formatting operand is specified, the output in the POSIX
locale shall be equivalent to specifying:

           date "+%a %b %e %H:%M:%S %Z %Y"
2019-04-12 19:40:34 -07:00
Michael Forney
6b950e436b sort: Use regular double for -n
`long double` may require software emulation and the (possible) extra
precision is unnecessary here.
2019-03-13 11:59:33 -07:00
Stephen Gregoratto
c30255e50a Fix typo 2018-11-21 10:45:43 -08:00
David Phillips
99c7876310 On glibc, include sysmacros.h directly
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.
2018-09-25 19:31:01 -07:00
Michael Forney
48d04ae446 find: Make -H and -L flag handling clearer 2018-09-25 19:16:19 -07:00
Mattias Andrée
d8656b0189 uname: check that no operands are specified
Signed-off-by: Mattias Andrée <maandree@kth.se>
2018-09-24 13:04:06 -07:00
Firas Khalil Khana
a1627b9419 ed: Changed delimiter to fix unterminated TODO comment 2018-09-23 11:02:31 +02:00
Roberto E. Vargas Caballero
6d3f18c821 ed: Add more bugs to TODO 2018-09-20 10:54:21 +02:00
Mattias Andrée
7441770cfd tty: fix exit value on error from 1 to 2
Signed-off-by: Mattias Andrée <maandree@kth.se>
2018-07-07 12:18:50 +01:00
Mattias Andrée
084b46ac51 dirname: support --
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>
2018-07-07 12:16:15 +01:00
Mattias Andrée
1d885159f2 basename: support --
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>
2018-07-07 12:16:11 +01:00
Roberto E. Vargas Caballero
f45156d5b4 Simplify expression in makeline()
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.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
18f6c5e014 Add TODO 2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
ece6569297 Fix undo
Avoid incorrect values in the number of undo elements and restore lastln
value after an undo operation.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
cd9b149c8f Use nextln() in scroll() 2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
ebf740f962 Improve doglobal()
Don't use directly the line numbers and call to getlst()
when a line is matched.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
9781959581 Fix copy()
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.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
504dde1373 Allow overlapping transfer 2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
d849e6d4aa Rename addchar_() to addchar()
All the ocurrences of addchar() were moved to addchar_(),
so we can rename addchar_() and remove the old definition.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
3ce26f33c6 Move subline() to use String type 2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
77fe371fe4 Fix type of c in getrhs()
C is compared against EOF, so it cannot be char.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
0732529fef Fix type of c in execsh()
C is compared against EOF, so it cannot be char.
2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
a5d268c409 Move execsh() to use String type 2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
8d59405ae0 Move join() to use String type 2018-07-03 09:31:46 +01:00
Roberto E. Vargas Caballero
7c2eec7bd1 Move lastre to String type 2018-07-03 09:31:46 +01:00