Skip to content

Commit

Permalink
Merge branch 'main' into feature/env_string_args_try_with_shell_words
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture authored Jan 15, 2024
2 parents 2a5d891 + 112eb21 commit 514a489
Show file tree
Hide file tree
Showing 22 changed files with 320 additions and 75 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,23 @@ jobs:
run: |
## Install/setup prerequisites
case '${{ matrix.job.target }}' in
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
*-redox*) sudo apt-get -y update ; sudo apt-get -y install fuse3 libfuse-dev ;;
arm-unknown-linux-gnueabihf)
sudo apt-get -y update
sudo apt-get -y install gcc-arm-linux-gnueabihf
;;
aarch64-unknown-linux-*)
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
;;
*-redox*)
sudo apt-get -y update
sudo apt-get -y install fuse3 libfuse-dev
;;
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
x86_64-pc-windows-gnu) C:/msys64/usr/bin/pacman.exe -Syu --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH ;;
x86_64-pc-windows-gnu)
C:/msys64/usr/bin/pacman.exe -Syu --needed mingw-w64-x86_64-gcc --noconfirm
echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
;;
esac
case '${{ matrix.job.os }}' in
macos-latest) brew install coreutils ;; # needed for testing
Expand Down
49 changes: 21 additions & 28 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ utf-8 = "0.7.6"
walkdir = "2.4"
winapi-util = "0.1.6"
windows-sys = { version = "0.48.0", default-features = false }
xattr = "1.2.0"
xattr = "1.3.1"
zip = { version = "0.6.6", default-features = false, features = ["deflate"] }

hex = "0.4.3"
Expand Down Expand Up @@ -500,6 +500,7 @@ rlimit = "0.10.1"
[target.'cfg(unix)'.dev-dependencies]
nix = { workspace = true, features = ["process", "signal", "user"] }
rand_pcg = "0.3"
xattr = { workspace = true }

[build-dependencies]
phf_codegen = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ skip = [
{ name = "syn", version = "1.0.109" },
# various crates
{ name = "bitflags", version = "1.3.2" },
# various crates
{ name = "redox_syscall", version = "0.3.5" },
# clap_builder, textwrap
{ name = "terminal_size", version = "0.2.6" },
]
Expand Down
3 changes: 2 additions & 1 deletion src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::io::{stdout, Read, Write};

use uucore::display::Quotable;
use uucore::encoding::{wrap_print, Data, Format};
use uucore::encoding::{wrap_print, Data, EncodeError, Format};
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::format_usage;

Expand Down Expand Up @@ -174,6 +174,7 @@ pub fn handle_input<R: Read>(
wrap_print(&data, &s);
Ok(())
}
Err(EncodeError::InvalidInput) => Err(USimpleError::new(1, "error: invalid input")),
Err(_) => Err(USimpleError::new(
1,
"error: invalid input (length must be multiple of 4 characters)",
Expand Down
9 changes: 7 additions & 2 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,13 @@ where
} else if filename.is_dir() {
Box::new(BufReader::new(io::empty())) as Box<dyn Read>
} else {
file_buf =
File::open(filename).map_err_context(|| filename.to_str().unwrap().to_string())?;
file_buf = match File::open(filename) {
Ok(file) => file,
Err(err) => {
show!(err.map_err_context(|| filename.to_string_lossy().to_string()));
continue;
}
};
Box::new(file_buf) as Box<dyn Read>
});
let (sum, sz) = digest_read(&mut options.digest, &mut file, options.output_bits)
Expand Down
12 changes: 8 additions & 4 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub enum TargetType {
}

/// Copy action to perform
#[derive(PartialEq)]
pub enum CopyMode {
Link,
SymLink,
Expand Down Expand Up @@ -825,6 +826,7 @@ impl Attributes {
ownership: Preserve::Yes { required: true },
mode: Preserve::Yes { required: true },
timestamps: Preserve::Yes { required: true },
xattr: Preserve::Yes { required: true },
..Self::NONE
};

Expand Down Expand Up @@ -1440,7 +1442,7 @@ pub(crate) fn copy_attributes(
})?;

handle_preserve(&attributes.xattr, || -> CopyResult<()> {
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "android")))]
{
let xattrs = xattr::list(source)?;
for attr in xattrs {
Expand All @@ -1449,7 +1451,7 @@ pub(crate) fn copy_attributes(
}
}
}
#[cfg(not(unix))]
#[cfg(not(all(unix, not(target_os = "android"))))]
{
// The documentation for GNU cp states:
//
Expand Down Expand Up @@ -1509,7 +1511,7 @@ fn backup_dest(dest: &Path, backup_path: &Path) -> CopyResult<PathBuf> {
///
/// Copying to the same file is only allowed if both `--backup` and
/// `--force` are specified and the file is a regular file.
fn is_forbidden_copy_to_same_file(
fn is_forbidden_to_copy_to_same_file(
source: &Path,
dest: &Path,
options: &Options,
Expand All @@ -1521,6 +1523,7 @@ fn is_forbidden_copy_to_same_file(
options.dereference(source_in_command_line) || !source.is_symlink();
paths_refer_to_same_file(source, dest, dereference_to_compare)
&& !(options.force() && options.backup != BackupMode::NoBackup)
&& !(dest.is_symlink() && options.backup != BackupMode::NoBackup)
}

/// Back up, remove, or leave intact the destination file, depending on the options.
Expand All @@ -1532,7 +1535,7 @@ fn handle_existing_dest(
) -> CopyResult<()> {
// Disallow copying a file to itself, unless `--force` and
// `--backup` are both specified.
if is_forbidden_copy_to_same_file(source, dest, options, source_in_command_line) {
if is_forbidden_to_copy_to_same_file(source, dest, options, source_in_command_line) {
return Err(format!("{} and {} are the same file", source.quote(), dest.quote()).into());
}

Expand Down Expand Up @@ -1714,6 +1717,7 @@ fn copy_file(
&& !options.force()
&& options.backup == BackupMode::NoBackup
&& source != dest
|| (source == dest && options.copy_mode == CopyMode::Link)
{
return Ok(());
}
Expand Down
11 changes: 9 additions & 2 deletions src/uu/expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ use std::fmt;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::num::IntErrorKind;
use std::path::Path;
use std::str::from_utf8;
use unicode_width::UnicodeWidthChar;
use uucore::display::Quotable;
use uucore::error::{FromIo, UError, UResult};
use uucore::{format_usage, help_about, help_usage};
use uucore::error::{set_exit_code, FromIo, UError, UResult};
use uucore::{format_usage, help_about, help_usage, show_error};

const ABOUT: &str = help_about!("expand.md");
const USAGE: &str = help_usage!("expand.md");
Expand Down Expand Up @@ -465,6 +466,12 @@ fn expand(options: &Options) -> UResult<()> {
let mut buf = Vec::new();

for file in &options.files {
if Path::new(file).is_dir() {
show_error!("{}: Is a directory", file);
set_exit_code(1);
continue;
}

let mut fh = open(file)?;

while match fh.read_until(b'\n', &mut buf) {
Expand Down
15 changes: 12 additions & 3 deletions src/uu/factor/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let stdin = stdin();
let lines = stdin.lock().lines();
for line in lines {
for number in line.unwrap().split_whitespace() {
print_factors_str(number, &mut w, print_exponents)
.map_err_context(|| "write error".into())?;
match line {
Ok(line) => {
for number in line.split_whitespace() {
print_factors_str(number, &mut w, print_exponents)
.map_err_context(|| "write error".into())?;
}
}
Err(e) => {
set_exit_code(1);
show_error!("error reading input: {}", e);
return Ok(());
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/uu/ls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ once_cell = { workspace = true }
selinux = { workspace = true, optional = true }
hostname = { workspace = true }

[target.'cfg(unix)'.dependencies]
xattr = { workspace = true }

[[bin]]
name = "ls"
path = "src/main.rs"
Expand Down
Loading

0 comments on commit 514a489

Please sign in to comment.