1
0
mirror of git://git.suckless.org/sbase synced 2025-03-11 07:17:56 +00:00
Commit Graph

2011 Commits

Author SHA1 Message Date
Roberto E. Vargas Caballero
2cbf61dff9 xargs: Read full lines is -I
POSIX specifies that when -I is used then arguments are delimited
only by newlines.
2023-09-22 14:19:36 +02:00
Roberto E. Vargas Caballero
fc85dc819d xargs: Free argument before substitution
strnsubst() allocates a new array always, indepently of
the number of occurences of the replace string.
2023-09-22 14:18:14 +02:00
Roberto E. Vargas Caballero
a1f0426699 xargs: Apply -I substitution to all the parameters
The substitution must happen in all the parameters that contain
the replacement string, but the code was soing the substitution
only once and in the parameter with an exact match.
Also, the argument length was not updated correctly, assuming
that the final argument had the size read from stdin.
2023-09-22 11:45:46 +02:00
Roberto E. Vargas Caballero
22f110db28 libutil: Remove free() from strnsub()
The free() was added in the wrong assumption that xargs was not
freeing the argument in the position replaced, but it actually
does it.

Also, removing the call to free() makes more general the function.
2023-09-22 11:44:58 +02:00
Roberto E. Vargas Caballero
4e8a096b1c xargs: Update the man page about -I 2023-09-22 10:54:08 +02:00
Roberto E. Vargas Caballero
b3a8052634 xargs: Add -x when -I is used
POSIX mandates to use -x when -I is used.
2023-09-22 10:37:18 +02:00
sewn
8d97acc135 xargs: add replace string flag (-I) 2023-09-22 10:34:36 +02:00
noneofyourbusiness
f14887c765 tr: fix behavior of cflag when using character classes
a simple test case:

printf ab3 | tr -c '[:alpha:]' '\n'

output should be ab<newline>, previously you would find just newlines.

Signed-off-by: noneofyourbusiness <noneofyourbusiness@danwin1210.de>
2023-09-21 15:27:01 +02:00
Heiko Berges
0b4c2ceb2f ed: Add support for ! in w command
When the file name begins with ! then the addressed buffer content is
piped to the name of the file that is considered a command that is
executed in a shell.
2023-09-21 15:14:16 +02:00
Richard Ipsum
53040766d1 cmp: Make output of error message POSIX compliant
From POSIX:

in the POSIX locale the following diagnostic message shall be written:

    "cmp: EOF on %s%s\n", <name of shorter file>, <additional info>

Amended by mcf: kept weprintf for consistency with other diagnostic
messages, but dropped the doubled prefix.
2023-04-12 21:37:04 -07:00
David Demelier
446903d688 libutf: add some const's 2023-04-12 21:22:28 -07:00
Michael Forney
7fc2f68aec libutf: Update to unicode 15.0.0 2023-04-12 21:20:56 -07:00
Greg Reagle
df50727a08 refer to re_format(7) for BSDs 2023-04-12 21:16:30 -07:00
Arthur Williams
8dfcbf23b0 cp: don't abort when src and dest file are the same
The POSIX spec gives many options on how to handle this case, but it
also states that cp (and mv) should continue with remaining operands
regardless. We used to exit immediately, which violates the spec.

This change makes cp/mv not exit immediately in this case and
also won't cause the return value to be non-zero.

From `man 1p cp`:
   If source_file references the same file as dest_file, cp may write
   a diagnostic message to standard error; it shall do nothing more
   with source_file and shall go on to any remaining files.
2023-04-12 21:09:12 -07:00
Andrea Calligaris
499c3b1227 sort.1: fix typo 2023-04-12 21:01:30 -07:00
Andrea Calligaris
93f34c1840 ed: Fix 'w' command not respecting '-s' option 2023-04-12 21:01:27 -07:00
Michael Forney
fb16e7c6ad dd: Consider block count in inner read loop
When ibs is smaller than obs, checking the block count in the outer
loop is not sufficient; we need to break out of the inner read loop
once we've read the specified number of blocks.

Thanks to phoebos for reporting this issue.
2023-04-12 20:47:34 -07:00
Michael Forney
00995639fe dd: Fix backwards comparison when handling short writes
ipos is always ahead of opos, so the left side of this condition
was never true. This only mattered when we get short writes, since
on EOF we always have less than a full output block, so it takes
only one normal write.
2023-04-12 20:09:51 -07:00
Michael Forney
191f7e693b find: insert -a in before open parens as well
This fixes expressions like -type f '(' -name foo -o -name bar ')'.
2022-10-21 18:31:52 -07:00
Hiltjo Posthuma
63271b47f7 setsid: fix usage information for -f flag 2022-06-20 12:39:59 +02:00
Michael Forney
c3e47c1f44 Fix LICENSE name
The license text matches (and has always matched) what is known as
the MIT license[0]. The MIT/X Consortium license, also called the
X11 license, is slightly different and has an additional clause
prohibiting various uses of the X Consortium name.

[0] https://opensource.org/licenses/MIT
2022-03-22 17:20:51 -07:00
Arthur Williams
2c2a7f54ab nohup: Open nohup.out WRONLY
Open nohup.out write-only instead of not specifying the access permissions
instead of getting undefined behavior (which probably results in stdout
not being writable).
2021-10-23 16:17:20 -07:00
Michael Forney
371f3cb5ec find: Flush stdout before executing commands
The commands may produce output themselves, so this is required to
ensure that our -print output is actually written before a command's
output, and also that we don't end up with partially written lines
due to stdout buffering intermixed with the output of other commands.

Other implementations of find(1) do the same.
2021-09-10 22:48:47 -07:00
Michael Forney
c331811c91 find: Add spawn helper function 2021-09-10 22:43:54 -07:00
Michael Forney
7d60e2cabb mv: Move on to other files if rename fails with something other than EXDEV 2021-07-30 12:24:32 -07:00
Michael Forney
df6599ef78 mv: Only remove source if copy succeeded 2021-07-30 12:09:34 -07:00
Michael Forney
688384568c mv: Prevent successful rename from forgetting past failure 2021-07-30 12:01:09 -07:00
Hiltjo Posthuma
1cc5a57fd7 printf: allow flags for the %s format string aswell
This is useful for example to left-align strings and pad them with spaces.

printf '%-12.12s: %s\n' 'user' "$USER"
2021-07-26 20:10:09 +02:00
Hiltjo Posthuma
61be841f5c tar: check if allocation failed 2021-07-18 10:53:51 -07:00
Michael Forney
3d8481f01d README: Add dd(1) to tool list 2021-06-17 19:09:25 -07:00
Michael Forney
4b76652eff dd: Always move excess to beginning of buffer after read/write loops
Otherwise, while we may have enough room for at least one input
block, we may not have enough room for an output block.
2021-05-21 12:16:41 -07:00
Michael Forney
7ef4038fb5 strings: Rename len to min 2021-01-14 21:46:30 -08:00
Michael Forney
5377a9c3d1 strings: Print strings that have the minimum length
Previously, there was an off-by-one error when determining whether
to print a strings, so when the string was exactly the minimum
length, it was not printed.

This fixes a bug with an x264 configure test, which expects to find
a string of length 4 (BIGE/EBIG) to detect system endianness.
2021-01-14 21:46:26 -08:00
Cág
3eb89c44aa ed: Fix double-free
After join() is called for the first time, s.str is left pointing
to a string that was just freed. Upon the second call to join(),
it is freed again at the start of the function.

Since the string is reset on every function call, there is no reason
for it to be static, so just replace the initial free with assignment
to NULL.
2020-10-19 14:50:47 -07:00
Richard Ipsum
172cdd98c3 fold: fix handling of -s 2020-10-14 15:03:20 -07:00
Richard Ipsum
cd9f55f5e1 fold: fix handling of multibyte characters 2020-10-14 15:03:20 -07:00
Richard Ipsum
db1dc984c3 fold: don't putchar('\n') if last byte is '\n' 2020-10-14 15:03:20 -07:00
Richard Ipsum
0d42b4f3d1 fold: fix handling of \b,\r 2020-10-14 15:03:20 -07:00
Richard Ipsum
75b5499a3a fold: fix tabstop column count 2020-10-14 15:03:20 -07:00
Michael Forney
ab53d99375 TODO: sbase-box does not list install in command list
Reported by Ethan Sommer
2020-09-18 19:58:22 -07:00
Michael Forney
a139474486 ed: Use fwrite to write lines instead of fputs
We already have the length of the line, so there is no point in
recalculating it before printing.
2020-09-18 19:58:22 -07:00
Tait Hoyem
714601b29d ed: Add bytecount print to 'w' command 2020-09-18 19:58:22 -07:00
Hiltjo Posthuma
0df09d5ba0 setsid: add optional -f to force fork() 2020-07-25 13:48:46 -07:00
Cem Keylan
991ff90064 remove sbase-box from PHONY
I have noticed this issue while I was trying to package sbase-box. Since
sbase-box was in the PHONY target, running sbase-box-install caused it to
be rebuilt when it was unnecessary. This also caused options passed to make
to be lost (such as LDFLAGS).
2020-07-03 13:18:23 -07:00
Michael Forney
f1c3fd4e44 Remove unnecessary initializers of recursor members 2020-06-23 02:20:41 -07:00
Michael Forney
fdb9084da9 libutil/recurse: Simplify adding trailing slash
We know that r->pathlen < sizeof(r->path) since r->path is
nul-terminated, so we can safely add a '/' here. If there is no
space left over for the rest of the path and nul-terminator, this
will be caught by the subsequent estrlcpy.
2020-06-20 18:48:14 -07:00
Richard Ipsum
5c76e79f41 du: recurse: fix path
path is not fixed up on exit from recursive step, this leads to
incorrect paths in du's output.

% find D
D
D/E
D/E/F
D/E/F/a2
D/E/F/b2
D/E/a1
D/E/b1
D/a
D/b

% du D
4       D/E/F
8       D/E
12      D

% ~/sbase/du D
4       D/E/F/b2
8       D/E/b1
12      D
2020-06-20 18:48:14 -07:00
Michael Forney
9e985c2bb2 install: Unlink destination file on failure 2020-05-24 20:58:36 -07:00
Michael Forney
8ef9b38e56 install: Use fchown to change owner 2020-05-24 20:56:50 -07:00
Richard Ipsum
8c02cf675c nl.1: document pages 2020-05-15 02:52:26 -07:00