Skip to content

Commit

Permalink
Merge remote-tracking branch 'uutils/main' into fix/gnu_test_dd_direc…
Browse files Browse the repository at this point in the history
…t_sh

# Conflicts:
#	Cargo.toml
  • Loading branch information
cre4ture committed Apr 30, 2024
2 parents 039ef96 + d6399f3 commit 910d33f
Show file tree
Hide file tree
Showing 24 changed files with 335 additions and 533 deletions.
29 changes: 15 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ hostname = "0.4"
humantime = "2.1.0"
indicatif = "0.17"
itertools = "0.12.1"
libc = "0.2.153"
libc = "0.2.154"
log = "0.4"
fern = { version = "0.6.2", default-features = false }
lscolors = { version = "0.16.0", default-features = false, features = [
Expand Down Expand Up @@ -330,13 +330,13 @@ textwrap = { version = "0.16.1", features = ["terminal_size"] }
thiserror = "1.0"
time = { version = "0.3" }
unicode-segmentation = "1.11.0"
unicode-width = "0.1.11"
unicode-width = "0.1.12"
utf-8 = "0.7.6"
walkdir = "2.5"
winapi-util = "0.1.8"
windows-sys = { version = "0.48.0", default-features = false }
xattr = "1.3.1"
zip = { version = "1.1.1", default-features = false, features = ["deflate"] }
zip = { version = "1.1.3", default-features = false, features = ["deflate"] }

hex = "0.4.3"
md-5 = "0.10.6"
Expand Down
7 changes: 7 additions & 0 deletions docs/src/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@ We support `--sort=name`, which makes it possible to override an earlier value.

`du` allows `birth` and `creation` as values for the `--time` argument to show the creation time. It
also provides a `-v`/`--verbose` flag.

## `id`

`id` has three additional flags:
* `-P` displays the id as a password file entry
* `-p` makes the output human-readable
* `-A` displays the process audit user ID
2 changes: 2 additions & 0 deletions src/uu/id/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ pub fn uu_app() -> Command {
.about(ABOUT)
.override_usage(format_usage(USAGE))
.infer_long_args(true)
.args_override_self(true)
.arg(
Arg::new(options::OPT_AUDIT)
.short('A')
Expand Down Expand Up @@ -396,6 +397,7 @@ pub fn uu_app() -> Command {
Arg::new(options::OPT_PASSWORD)
.short('P')
.help("Display the id as a password file entry.")
.conflicts_with(options::OPT_HUMAN_READABLE)
.action(ArgAction::SetTrue),
)
.arg(
Expand Down
20 changes: 15 additions & 5 deletions src/uu/kill/src/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use nix::unistd::Pid;
use std::io::Error;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::signals::{signal_by_name_or_value, ALL_SIGNALS};
use uucore::signals::{signal_by_name_or_value, signal_name_by_value, ALL_SIGNALS};
use uucore::{format_usage, help_about, help_usage, show};

static ABOUT: &str = help_about!("kill.md");
Expand Down Expand Up @@ -60,9 +60,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} else {
15_usize //SIGTERM
};
let sig: Signal = (sig as i32)
.try_into()
.map_err(|e| std::io::Error::from_raw_os_error(e as i32))?;

let sig_name = signal_name_by_value(sig);
// Signal does not support converting from EXIT
// Instead, nix::signal::kill expects Option::None to properly handle EXIT
let sig: Option<Signal> = if sig_name.is_some_and(|name| name == "EXIT") {
None
} else {
let sig = (sig as i32)
.try_into()
.map_err(|e| std::io::Error::from_raw_os_error(e as i32))?;
Some(sig)
};

let pids = parse_pids(&pids_or_signals)?;
if pids.is_empty() {
Err(USimpleError::new(
Expand Down Expand Up @@ -211,7 +221,7 @@ fn parse_pids(pids: &[String]) -> UResult<Vec<i32>> {
.collect()
}

fn kill(sig: Signal, pids: &[i32]) {
fn kill(sig: Option<Signal>, pids: &[i32]) {
for &pid in pids {
if let Err(e) = signal::kill(Pid::from_raw(pid), sig) {
show!(Error::from_raw_os_error(e as i32)
Expand Down
4 changes: 3 additions & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ impl Output {
let file = if let Some(name) = name {
// This is different from `File::create()` because we don't truncate the output yet.
// This allows using the output file as an input file.
#[allow(clippy::suspicious_open_options)]
// clippy::suspicious_open_options supported only for Rust >= 1.77.0
// Rust version = 1.76 on OpenBSD stable/7.5
#[cfg_attr(not(target_os = "openbsd"), allow(clippy::suspicious_open_options))]
let file = OpenOptions::new()
.write(true)
.create(true)
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tail/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum ParseError {
InvalidEncoding,
}
/// Parses obsolete syntax
/// tail -\[NUM\]\[bcl\]\[f\] and tail +\[NUM\]\[bcl\]\[f\] // spell-checker:disable-line
/// tail -\[NUM\]\[bcl\]\[f\] and tail +\[NUM\]\[bcl\]\[f\]
pub fn parse_obsolete(src: &OsString) -> Option<Result<ObsoleteArgs, ParseError>> {
let mut rest = match src.to_str() {
Some(src) => src,
Expand Down
4 changes: 2 additions & 2 deletions src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ time = { workspace = true, optional = true, features = [
"macros",
] }
# * "problem" dependencies (pinned)
data-encoding = { version = "2.5", optional = true }
data-encoding-macro = { version = "0.1.14", optional = true }
data-encoding = { version = "2.6", optional = true }
data-encoding-macro = { version = "0.1.15", optional = true }
z85 = { version = "3.0.5", optional = true }
libc = { workspace = true, optional = true }
once_cell = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions src/uucore/src/lib/features/fsext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,22 @@ use libc::c_int;
))]
extern "C" {
#[cfg(all(target_vendor = "apple", target_arch = "x86_64"))]
#[link_name = "getmntinfo$INODE64"] // spell-checker:disable-line
#[link_name = "getmntinfo$INODE64"]
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;

#[cfg(any(
target_os = "netbsd",
target_os = "openbsd",
all(target_vendor = "apple", target_arch = "aarch64")
))]
#[link_name = "getmntinfo"] // spell-checker:disable-line
#[link_name = "getmntinfo"]
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;

// Rust on FreeBSD uses 11.x ABI for filesystem metadata syscalls.
// Call the right version of the symbol for getmntinfo() result to
// match libc StatFS layout.
#[cfg(target_os = "freebsd")]
#[link_name = "getmntinfo@FBSD_1.0"] // spell-checker:disable-line
#[link_name = "getmntinfo@FBSD_1.0"]
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/by-util/test_basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn test_multiple_param() {
new_ucmd!()
.args(&[multiple_param, path, path])
.succeeds()
.stdout_only("baz\nbaz\n"); // spell-checker:disable-line
.stdout_only("baz\nbaz\n");
}
}

Expand All @@ -81,7 +81,7 @@ fn test_suffix_param() {
new_ucmd!()
.args(&[suffix_param, ".exe", path, path])
.succeeds()
.stdout_only("baz\nbaz\n"); // spell-checker:disable-line
.stdout_only("baz\nbaz\n");
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/by-util/test_basenc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ fn test_base64() {
.pipe_in("to>be?")
.succeeds()
.no_stderr()
.stdout_only("dG8+YmU/\n"); // spell-checker:disable-line
.stdout_only("dG8+YmU/\n");
}

#[test]
fn test_base64_decode() {
new_ucmd!()
.args(&["--base64", "-d"])
.pipe_in("dG8+YmU/") // spell-checker:disable-line
.pipe_in("dG8+YmU/")
.succeeds()
.no_stderr()
.stdout_only("to>be?");
Expand All @@ -61,14 +61,14 @@ fn test_base64url() {
.pipe_in("to>be?")
.succeeds()
.no_stderr()
.stdout_only("dG8-YmU_\n"); // spell-checker:disable-line
.stdout_only("dG8-YmU_\n");
}

#[test]
fn test_base64url_decode() {
new_ucmd!()
.args(&["--base64url", "-d"])
.pipe_in("dG8-YmU_") // spell-checker:disable-line
.pipe_in("dG8-YmU_")
.succeeds()
.no_stderr()
.stdout_only("to>be?");
Expand Down
6 changes: 2 additions & 4 deletions tests/by-util/test_cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore NOFILE
// spell-checker:ignore NOFILE nonewline

#[cfg(not(windows))]
use crate::common::util::vec_of_size;
Expand All @@ -23,7 +23,6 @@ fn test_output_simple() {

#[test]
fn test_no_options() {
// spell-checker:disable-next-line
for fixture in ["empty.txt", "alpha.txt", "nonewline.txt"] {
// Give fixture through command line file argument
new_ucmd!()
Expand Down Expand Up @@ -196,7 +195,6 @@ fn test_directory() {
fn test_directory_and_file() {
let s = TestScenario::new(util_name!());
s.fixtures.mkdir("test_directory2");
// spell-checker:disable-next-line
for fixture in ["empty.txt", "alpha.txt", "nonewline.txt"] {
s.ucmd()
.args(&["test_directory2", fixture])
Expand All @@ -219,7 +217,7 @@ fn test_three_directories_and_file_and_stdin() {
"alpha.txt",
"-",
"file_which_does_not_exist.txt",
"nonewline.txt", // spell-checker:disable-line
"nonewline.txt",
"test_directory3/test_directory5",
"test_directory3/../test_directory3/test_directory5",
"test_directory3",
Expand Down
Loading

0 comments on commit 910d33f

Please sign in to comment.