Commit graph

8112 commits

Author SHA1 Message Date
Teemu Pätsi
4ee53acad0
expr: Fix parsing negated character classes "[^a]" (#7884)
* expr: Fix regex escape logic

We have to track if the previous character was already escaped to determine
if the '\' character should be interpreted as an escape character.

* expr: Fix parsing caret (^) as character class negation token

* expr: Add tests for parsing carets in regex

* expr: Add missing semicolon

* expr: Simplify boolean assignment

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-05-04 17:35:18 +02:00
Daniel Hofstetter
69d5cf40b1
Merge pull request #7877 from yuankunzhang/main
split: fix a racing condition that causes issue #7869
2025-05-04 14:39:09 +02:00
Daniel Hofstetter
15b6f40cfd
cp: use authors.workspace in Cargo.toml (#7882) 2025-05-04 13:20:48 +02:00
Daniel Hofstetter
8c4d69b2f6
Merge pull request #7845 from sylvestre/selinux-error
set_selinux_security_context should return an Error, not String
2025-05-04 12:45:53 +02:00
yuankunzhang
d412f582cb split: fix a racing condition that causes issue #7869 2025-05-04 16:49:03 +08:00
Piepmatz
c8dbd185c0
Allow compiling uucore with wasm32-unknown-unknown (#7840)
and fix the build
2025-05-04 09:41:51 +02:00
Teemu Pätsi
d3a2db415c
id: The --real flag should only affect -u, -g, and -G (#7796)
* id: The `--real` flag should only affect `-u`, `-g`, and `-U`

* id: Test output with different UID and EUID

* id: Simplify testing different UID and EUID

* id: Compile preload file for test using cc instead of gcc

* id: Remove test for different UID and EUID

The test is incompatible with some CI/CD targets.

This reverts the following commits:
- 8efcbf9ada
- 208fa8e7f8
- a498a2722d
2025-05-04 09:38:34 +02:00
Daniel Hofstetter
cd3c921d1e
cp: copy dir if source path ends with dot (#7874) 2025-05-04 09:31:34 +02:00
Sylvestre Ledru
c177362a51 set_selinux_security_context: also display the error from the crate
+ fix comments from review
2025-05-03 23:16:43 +02:00
Dorian Péron
f49e120877
Merge pull request #7846 from frendsick/fix/expr-regex-option-singleline
expr: Fix regex anchor matching behavior with `REGEX_OPTION_SINGLELINE`
2025-05-02 13:35:10 +02:00
Daniel Hofstetter
64d308db0e install: use map_err instead of if let Err 2025-05-02 09:09:47 +02:00
Daniel Hofstetter
74d04c26f0 install: remove three todos 2025-05-02 09:09:47 +02:00
Zhang Wen
68c91c17ba
install: implement the --no-target-directory option (#7867)
* implement --no-target-directory option

* add test for --no-target-directory
2025-05-02 07:24:16 +02:00
Sylvestre Ledru
595f56a9e7 set_selinux_security_context: match GNU's error 2025-05-01 14:10:13 +02:00
Sylvestre Ledru
8d94add393 set_selinux_security_context split the ContextRetrievalFailure error in two 2025-05-01 14:10:13 +02:00
Sylvestre Ledru
3bc267902c set_selinux_security_context should return an Error, not String 2025-05-01 14:10:13 +02:00
Dorian Péron
279629f67e
Merge pull request #7855 from jtracey/printf-nonzero
printf: use non-zero indexes
2025-04-30 16:32:31 +02:00
Leo Emar-Kar
b14388ca41
ls: update chrono crate version and switch to new_lenient use (#7858)
* update chrono crate version and switch to new_lenient use

* bring back custom_tz_fmt and update test

* update chrono version in fuzz lock file

* replace boxing with parse_to_owned
2025-04-29 16:29:42 +02:00
Nicolas Boichat
25e4410c3b date: Properly support %#z, instead of rejecting the format
It's easy to just replace %#z with %z as the capitalization makes
no sense anyway.
2025-04-29 21:35:00 +08:00
Justin Tracey
27487be267
printf: use non-zero indexes 2025-04-28 14:06:12 -04:00
Dan Hipschman
e92e419a93 cp: refuse to copy symlink over itself 2025-04-28 09:56:43 +02:00
bitspill
d957e64999
Merge pull request #7492 from bitspill/rm
rm: skip prompt when stdin is not interactive; Fix #7326
2025-04-27 23:54:16 +02:00
Teemu Pätsi
07501be4ae
expr: Escape anchor characters within pattern (#7842)
* expr: Escape anchor characters within the core pattern

The anchor characters `^` and `$` are not considered special characters by `expr`
unless they are used as expected on the start or end of the pattern.
2025-04-27 23:52:35 +02:00
Teemu Pätsi
8cd51227c6
expr: Fix regex anchor matching behavior with REGEX_OPTION_SINGLELINE
The previously used `REGEX_OPTION_NONE` allowed anchors (^) and ($) to match across newlines.

New anchor behaviors:
- `^` matches the start of the entire string (`\A`)
- `$` matches the end of the entire string (`\Z`)
2025-04-26 18:22:22 +03:00
Sylvestre Ledru
606c0c1f57
Merge pull request #7837 from sargas/add-indexing-to-printf
printf: Add indexing to format strings
2025-04-25 23:58:01 +02:00
Daniel Hofstetter
0ec36bef11
Merge pull request #7838 from zcg00/install_deletes_files
install: fixes issue #7795
2025-04-25 15:10:11 +02:00
Zachary Goff-Hodges
827d0fcee9
install: fixes issue #7795 2025-04-25 03:48:50 -07:00
Daniel Hofstetter
c5fba4bfd8
Merge pull request #7831 from sylvestre/selinux-mkfifo
mkfifo: implement selinux support
2025-04-25 09:11:50 +02:00
Joseph Jon Booker
7f98d98472 printf: Add indexing to format strings 2025-04-24 22:11:49 -05:00
Sylvestre Ledru
18db15e4e6
Merge pull request #7208 from jtracey/printf-go
printf: improve support of printing multi-byte values of characters
2025-04-24 22:02:13 +02:00
Sylvestre Ledru
8298173554 mkfifo: implement selinux support
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

merge
2025-04-24 21:54:12 +02:00
Daniel Hofstetter
2b5391e6eb id: fix error message & simplify tests 2025-04-24 15:21:11 +02:00
Jeremy Smart
b151e039ae
shred: fix random passes* (#7830)
* shred: fix random passes, update documentation, add test

* shred: update tests
2025-04-24 09:15:36 +02:00
Jeremy Smart
044b33d8cb
Merge pull request #7760 from Qelxiros/7670-tail-hex-formatting
tail hex parsing, remove fundu dependency
2025-04-23 18:34:00 +02:00
Daniel Hofstetter
be4e6913a5 mknod: cleanup dev handling 2025-04-23 11:49:29 +02:00
Daniel Hofstetter
a3c181dce3 mknod: cleanup mode handling 2025-04-23 11:37:47 +02:00
Daniel Hofstetter
482f882b4c
mknod: rename function _mknod to mknod (#7824) 2025-04-23 11:03:37 +02:00
Daniel Hofstetter
67400abd70
Merge pull request #7818 from sylvestre/selinux-mknod
mknod: implement selinux support
2025-04-23 09:38:09 +02:00
Sylvestre Ledru
c9babe4e6f mknod: pass a string instead of matches 2025-04-23 08:37:42 +02:00
Sylvestre Ledru
aebada4cd4 mknod: implement selinux support
+ improve the option management a bit
2025-04-23 08:37:42 +02:00
Teemu Pätsi
6ac444a9c6
id: Handle NULL pointer gracefully within cstr2cow macro (#7810)
* id: Handle NULL pointer gracefully within `cstr2cow` macro

> getlogin() returns a pointer to a string containing the name of the user logged in on the controlling terminal of the process, or a NULL pointer if this information cannot be determined.

Ref: https://linux.die.net/man/3/getlogin

* id: Remove redundant std::ffi:: prefix from CStr

* id: Add comment for the null check

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>

* id: Remove skip for test that should not segfault anymore

Segfault fixed by 292fb92423

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-04-23 08:26:00 +02:00
Sylvestre Ledru
a4230410c8
Merge pull request #7821 from cakebaker/mknod_remove_windows_code_flags
mknod: remove windows-related code & flags
2025-04-22 17:32:10 +02:00
Daniel Hofstetter
9e7f3acbc7 mknod: remove windows-related code & flags 2025-04-22 16:57:26 +02:00
Sylvestre Ledru
1986c965cc
Merge pull request #7782 from drinkcat/seq-perf-more-use-cat
Move seq's `fast_inc` to `uucore`, use it in `cat`
2025-04-22 15:54:00 +02:00
Sylvestre Ledru
96b714781a
Merge pull request #7813 from drinkcat/ls-opt-2
ls: More performance optimizations
2025-04-22 15:53:36 +02:00
Sylvestre Ledru
77c4ba5bea
Merge pull request #7241 from jfinkels/mv-copy-across-filesystems
mv: fix moving FIFO to a different filesystem
2025-04-21 23:03:26 +02:00
Sylvestre Ledru
83679a3956
Merge pull request #7790 from drinkcat/num_parser_simplify
uucore: num_parser: Operate on slices, instead of iterator
2025-04-21 22:50:05 +02:00
Nicolas Boichat
fc6b896c27 ls: Optimize time formatting
Instead of recreating the formatter over and over again, keep
it pre-parsed in a variable in TimeStyler class.

Also, avoid calling `now` over and over again, that's also slow.

Improves performance by about 6%.
2025-04-21 12:19:14 +02:00
Nicolas Boichat
b833deb8d1 ls: display_uname/group: Return a reference
Cache even numerical strings (numeric_uid_gid) in the HashMap,
this makes very little difference performance wise.

However, this allows us to return a reference to a String instead
of making a clone.

Saves about 2-3% on `ls -lR /var/lib .git` (and `ls -lRn`).

Also, add a note that HashMap might not be the most optimal choice.
2025-04-21 12:19:14 +02:00
Nicolas Boichat
1890467bd7 ls: ListState: Add uid/gid cache to the structure
Easier to reason about than the LazyLock/Mutex encapsulated
static variables.

Performance difference is not measurable, but this drops uneeded
Mutex lock/unlock that were seen in samply output.
2025-04-21 12:19:14 +02:00