Skip to content

Commit 4f83924

Browse files
authored
Merge branch 'main' into sort-mem-percent
2 parents 94c772c + 5d6a04a commit 4f83924

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+890
-411
lines changed

.github/workflows/CICD.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ jobs:
417417
--arg multisize "$SIZE_MULTI" \
418418
'{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json
419419
- name: Download the previous individual size result
420-
uses: dawidd6/action-download-artifact@v7
420+
uses: dawidd6/action-download-artifact@v8
421421
with:
422422
workflow: CICD.yml
423423
name: individual-size-result
424424
repo: uutils/coreutils
425425
path: dl
426426
- name: Download the previous size result
427-
uses: dawidd6/action-download-artifact@v7
427+
uses: dawidd6/action-download-artifact@v8
428428
with:
429429
workflow: CICD.yml
430430
name: size-result

.github/workflows/GnuTests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
working-directory: ${{ steps.vars.outputs.path_GNU }}
9292

9393
- name: Retrieve reference artifacts
94-
uses: dawidd6/action-download-artifact@v7
94+
uses: dawidd6/action-download-artifact@v8
9595
# ref: <https://github.com/dawidd6/action-download-artifact>
9696
continue-on-error: true ## don't break the build for missing reference artifacts (may be expired or just not generated yet)
9797
with:
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
## Install dependencies
107107
sudo apt-get update
108-
sudo apt-get install -y autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev libselinux1-dev attr
108+
sudo apt-get install -y autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev libselinux1-dev attr quilt
109109
- name: Add various locales
110110
shell: bash
111111
run: |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
tests/tail/inotify-dir-recreate
22
tests/timeout/timeout
33
tests/rm/rm1
4+
tests/misc/stdbuf
5+
tests/misc/usage_vs_getopt

Cargo.lock

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ semicolon_if_nothing_returned = "warn"
576576
single_char_pattern = "warn"
577577
explicit_iter_loop = "warn"
578578
if_not_else = "warn"
579+
manual_if_else = "warn"
579580

580581
all = { level = "deny", priority = -1 }
581582
cargo = { level = "warn", priority = -1 }

DEVELOPMENT.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl
241241

242242
Note that GNU test suite relies on individual utilities (not the multicall binary).
243243

244+
You also need to install [quilt](https://savannah.nongnu.org/projects/quilt), a tool used to manage a stack of patches for modifying GNU tests.
245+
244246
On FreeBSD, you need to install packages for GNU coreutils and sed (used in shell scripts instead of system commands):
245247

246248
```shell

src/uu/basename/src/basename.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,13 @@ fn basename(fullname: &str, suffix: &str) -> String {
125125

126126
// Convert to path buffer and get last path component
127127
let pb = PathBuf::from(path);
128-
match pb.components().last() {
129-
Some(c) => {
130-
let name = c.as_os_str().to_str().unwrap();
131-
if name == suffix {
132-
name.to_string()
133-
} else {
134-
name.strip_suffix(suffix).unwrap_or(name).to_string()
135-
}
136-
}
137128

138-
None => String::new(),
139-
}
129+
pb.components().next_back().map_or_else(String::new, |c| {
130+
let name = c.as_os_str().to_str().unwrap();
131+
if name == suffix {
132+
name.to_string()
133+
} else {
134+
name.strip_suffix(suffix).unwrap_or(name).to_string()
135+
}
136+
})
140137
}

src/uu/cksum/src/cksum.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use std::iter;
1313
use std::path::Path;
1414
use uucore::checksum::{
1515
calculate_blake2b_length, detect_algo, digest_reader, perform_checksum_validation,
16-
ChecksumError, ChecksumOptions, ALGORITHM_OPTIONS_BLAKE2B, ALGORITHM_OPTIONS_BSD,
17-
ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV, SUPPORTED_ALGORITHMS,
16+
ChecksumError, ChecksumOptions, ChecksumVerbose, ALGORITHM_OPTIONS_BLAKE2B,
17+
ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV,
18+
SUPPORTED_ALGORITHMS,
1819
};
1920
use uucore::{
2021
encoding,
@@ -322,13 +323,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
322323
|| iter::once(OsStr::new("-")).collect::<Vec<_>>(),
323324
|files| files.map(OsStr::new).collect::<Vec<_>>(),
324325
);
326+
327+
let verbose = ChecksumVerbose::new(status, quiet, warn);
328+
325329
let opts = ChecksumOptions {
326330
binary: binary_flag,
327331
ignore_missing,
328-
quiet,
329-
status,
330332
strict,
331-
warn,
333+
verbose,
332334
};
333335

334336
return perform_checksum_validation(files.iter().copied(), algo_option, length, opts);
@@ -462,19 +464,22 @@ pub fn uu_app() -> Command {
462464
.short('w')
463465
.long("warn")
464466
.help("warn about improperly formatted checksum lines")
465-
.action(ArgAction::SetTrue),
467+
.action(ArgAction::SetTrue)
468+
.overrides_with_all([options::STATUS, options::QUIET]),
466469
)
467470
.arg(
468471
Arg::new(options::STATUS)
469472
.long("status")
470473
.help("don't output anything, status code shows success")
471-
.action(ArgAction::SetTrue),
474+
.action(ArgAction::SetTrue)
475+
.overrides_with_all([options::WARN, options::QUIET]),
472476
)
473477
.arg(
474478
Arg::new(options::QUIET)
475479
.long(options::QUIET)
476480
.help("don't print OK for each successfully verified file")
477-
.action(ArgAction::SetTrue),
481+
.action(ArgAction::SetTrue)
482+
.overrides_with_all([options::WARN, options::STATUS]),
478483
)
479484
.arg(
480485
Arg::new(options::IGNORE_MISSING)

src/uu/date/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ path = "src/date.rs"
2020
[dependencies]
2121
chrono = { workspace = true }
2222
clap = { workspace = true }
23-
uucore = { workspace = true }
23+
uucore = { workspace = true, features = ["custom-tz-fmt"] }
2424
parse_datetime = { workspace = true }
25-
chrono-tz = { workspace = true }
26-
iana-time-zone = { workspace = true }
2725

2826
[target.'cfg(unix)'.dependencies]
2927
libc = { workspace = true }

src/uu/date/src/date.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes
77

88
use chrono::format::{Item, StrftimeItems};
9-
use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, TimeZone, Utc};
9+
use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, Utc};
1010
#[cfg(windows)]
1111
use chrono::{Datelike, Timelike};
12-
use chrono_tz::{OffsetName, Tz};
1312
use clap::{crate_version, Arg, ArgAction, Command};
14-
use iana_time_zone::get_timezone;
1513
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
1614
use libc::{clock_settime, timespec, CLOCK_REALTIME};
1715
use std::fs::File;
1816
use std::io::{BufRead, BufReader};
1917
use std::path::PathBuf;
18+
use uucore::custom_tz_fmt::custom_time_format;
2019
use uucore::display::Quotable;
2120
use uucore::error::FromIo;
2221
use uucore::error::{UResult, USimpleError};
@@ -274,21 +273,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
274273
for date in dates {
275274
match date {
276275
Ok(date) => {
277-
// TODO - Revisit when chrono 0.5 is released. https://github.com/chronotope/chrono/issues/970
278-
let tz = match std::env::var("TZ") {
279-
// TODO Support other time zones...
280-
Ok(s) if s == "UTC0" || s.is_empty() => Tz::Etc__UTC,
281-
_ => match get_timezone() {
282-
Ok(tz_str) => tz_str.parse().unwrap(),
283-
Err(_) => Tz::Etc__UTC,
284-
},
285-
};
286-
let offset = tz.offset_from_utc_date(&Utc::now().date_naive());
287-
let tz_abbreviation = offset.abbreviation();
288-
// GNU `date` uses `%N` for nano seconds, however crate::chrono uses `%f`
289-
let format_string = &format_string
290-
.replace("%N", "%f")
291-
.replace("%Z", tz_abbreviation.unwrap_or("UTC"));
276+
let format_string = custom_time_format(format_string);
292277
// Refuse to pass this string to chrono as it is crashing in this crate
293278
if format_string.contains("%#z") {
294279
return Err(USimpleError::new(
@@ -298,7 +283,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
298283
}
299284
// Hack to work around panic in chrono,
300285
// TODO - remove when a fix for https://github.com/chronotope/chrono/issues/623 is released
301-
let format_items = StrftimeItems::new(format_string);
286+
let format_items = StrftimeItems::new(format_string.as_str());
302287
if format_items.clone().any(|i| i == Item::Error) {
303288
return Err(USimpleError::new(
304289
1,

0 commit comments

Comments
 (0)