Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: CICD
# spell-checker:ignore (abbrev/names) CACHEDIR CICD CodeCOV MacOS MinGW MSVC musl taiki
# spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic Dwarnings RUSTDOCFLAGS RUSTFLAGS Zpanic CARGOFLAGS CLEVEL nodocs
# spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel profdata
# spell-checker:ignore (people) Peltoche rivy dtolnay Anson dawidd
# spell-checker:ignore (people) Peltoche rivy Anson dawidd
# spell-checker:ignore (shell/tools) binutils choco clippy dmake esac fakeroot fdesc fdescfs gmake grcov halium lcov libclang libfuse libssl limactl nextest nocross pacman popd printf pushd redoxer rsync rustc rustfmt rustup shopt sccache utmpdump xargs zstd
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils libsystemd codspeed wasip libexecinfo
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest tempfile testsuite toybox uutils libsystemd codspeed wasip libexecinfo

env:
PROJECT_NAME: coreutils
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/FixPR.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: FixPR

# spell-checker:ignore Swatinem dtolnay dedupe
# spell-checker:ignore dedupe

# Trigger automated fixes for PRs being merged (with associated commits)

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/GnuTests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: GnuTests

# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests Swatinem
# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests
# spell-checker:ignore (jargon) submodules devel
# spell-checker:ignore (libs/utils) chksum dpkg getenforce gperf lcov libexpect limactl pyinotify setenforce shopt valgrind libattr libcap taiki-e zstd cpio
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic
# spell-checker:ignore (people) Dawid Dziurla * dawidd dtolnay
# spell-checker:ignore (people) Dawid Dziurla * dawidd
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS
# spell-checker:ignore userns nodocs

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Android

# spell-checker:ignore (people) reactivecircus Swatinem dtolnay juliangruber
# spell-checker:ignore (people) reactivecircus juliangruber
# spell-checker:ignore (shell/tools) TERMUX nextest udevadm pkill
# spell-checker:ignore (misc) swiftshader playstore DATALOSS noaudio

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Benchmarks

# spell-checker:ignore (people) dtolnay Swatinem taiki-e
# spell-checker:ignore (people) taiki-e
# spell-checker:ignore (misc) codspeed sccache

on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Code Quality

# spell-checker:ignore (people) dtolnay juliangruber pell reactivecircus Swatinem taiki-e taplo
# spell-checker:ignore (people) juliangruber pell reactivecircus taiki-e taplo
# spell-checker:ignore (misc) TERMUX noaudio pkill swiftshader esac sccache pcoreutils shopt subshell dequote libsystemd

on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# spell-checker:ignore dtolnay libsystemd libattr libcap gsub
# spell-checker:ignore libsystemd libattr libcap gsub

name: Check uudoc Documentation Generation

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: FreeBSD

# spell-checker:ignore sshfs usesh vmactions taiki Swatinem esac fdescfs fdesc nextest copyback logind
# spell-checker:ignore sshfs usesh vmactions taiki esac fdescfs fdesc nextest copyback logind

env:
# * style job configuration
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Fuzzing

# spell-checker:ignore (people) dtolnay Swatinem taiki-e
# spell-checker:ignore (people) taiki-e
# spell-checker:ignore (misc) fuzzer

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: make
# spell-checker:ignore (jargon) deps softprops toolchain
# spell-checker:ignore (people) dawidd
# spell-checker:ignore (shell/tools) nextest sccache zstd
# spell-checker:ignore (misc) bindir busytest defconfig DESTDIR manpages multisize runtest Swatinem testsuite toybox uutils
# spell-checker:ignore (misc) bindir busytest defconfig DESTDIR manpages multisize runtest testsuite toybox uutils

env:
PROJECT_NAME: coreutils
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manpage-lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# spell-checker:ignore mandoc uudoc manpages dtolnay libsystemd libattr libcap DESTDIR
# spell-checker:ignore mandoc uudoc manpages libsystemd libattr libcap DESTDIR

name: Manpage Validation

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openbsd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: OpenBSD

# spell-checker:ignore sshfs usesh vmactions taiki Swatinem esac fdescfs fdesc sccache nextest copyback logind bindgen libclang
# spell-checker:ignore sshfs usesh vmactions taiki esac fdescfs fdesc sccache nextest copyback logind bindgen libclang

env:
# * style job configuration
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/wasi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# spell-checker:ignore wasip wasmtime
name: WASI

# spell-checker:ignore TRIGGERPATH
on:
pull_request:
push:
branches:
- main

permissions:
contents: read

# End the current execution if there is a new changeset in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
test_wasi:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1
- uses: Swatinem/rust-cache@v2
- name: Install wasmtime
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
- name: Run tests
env:
CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
run: |
cargo test --target wasm32-wasip1 --no-default-features -p uu_echo -p uu_cut
4 changes: 4 additions & 0 deletions .vscode/cspell.dictionaries/jargon.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ vals
inval
nofield

# ci
dtolnay
Swatinem

# * clippy
uninlined
nonminimal
Expand Down
19 changes: 18 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ feat_Tier1 = [
# It is bit complex to deduplicate with other lists
feat_wasm = [
"arch",
"basename",
"base32",
"base64",
"basenc",
"basename",
"cat",
"comm",
"cp",
"csplit",
"cut",
"ls",
"date",
"dir",
"dircolors",
"dirname",
"echo",
Expand All @@ -197,10 +200,15 @@ feat_wasm = [
"false",
"fmt",
"fold",
"head",
"join",
"link",
"ln",
"ls",
"mkdir",
"mv",
"nl",
"nproc",
"numfmt",
"od",
"paste",
Expand All @@ -211,21 +219,30 @@ feat_wasm = [
"printf",
"ptx",
"pwd",
"readlink",
"realpath",
"rm",
"rmdir",
"seq",
"sort",
"split",
"shred",
"shuf",
"sleep",
"sort",
"sum",
"tail",
"tee",
"touch",
"tr",
"true",
"truncate",
"tsort",
"uname",
"unexpand",
"uniq",
"unlink",
"vdir",
"wc",
"yes",
# cksum family
Expand Down
19 changes: 11 additions & 8 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1896,17 +1896,17 @@ pub(crate) fn copy_attributes(
fn symlink_file(
source: &Path,
dest: &Path,
symlinked_files: &mut HashSet<FileInformation>,
#[cfg(not(target_os = "wasi"))] symlinked_files: &mut HashSet<FileInformation>,
#[cfg(target_os = "wasi")] _symlinked_files: &mut HashSet<FileInformation>,
) -> CopyResult<()> {
#[cfg(target_os = "wasi")]
{
return Err(CpError::IoErrContext(
std::io::Error::new(std::io::ErrorKind::Unsupported, "symlinks not supported"),
Err(CpError::IoErrContext(
io::Error::new(io::ErrorKind::Unsupported, "symlinks not supported"),
translate!("cp-error-cannot-create-symlink",
"dest" => get_filename(dest).unwrap_or("?").quote(),
"source" => get_filename(source).unwrap_or("?").quote()),
)
.into());
))
}
#[cfg(not(any(windows, target_os = "wasi")))]
{
Expand All @@ -1930,10 +1930,13 @@ fn symlink_file(
)
})?;
}
if let Ok(file_info) = FileInformation::from_path(dest, false) {
symlinked_files.insert(file_info);
#[cfg(not(target_os = "wasi"))]
{
if let Ok(file_info) = FileInformation::from_path(dest, false) {
symlinked_files.insert(file_info);
}
Ok(())
}
Ok(())
}

fn context_for(src: &Path, dest: &Path) -> String {
Expand Down
7 changes: 7 additions & 0 deletions src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,12 +718,19 @@ fn format_date_with_locale_aware_months(

let broken_down = BrokenDownTime::from(date);

// When the i18n-datetime feature is enabled (default), use ICU locale-aware
// formatting if the locale requires it. Without the feature (e.g. wasi/wasm
// builds that use --no-default-features), skip localization entirely and
// format with the raw strftime string.
#[cfg(feature = "i18n-datetime")]
let result = if !should_use_icu_locale() || skip_localization {
broken_down.to_string_with_config(config, format_string)
} else {
let fmt = localize_format_string(format_string, date.date());
broken_down.to_string_with_config(config, &fmt)
};
#[cfg(not(feature = "i18n-datetime"))]
let result = broken_down.to_string_with_config(config, format_string);

result.map_err(|e| e.to_string())
}
Expand Down
8 changes: 8 additions & 0 deletions src/uu/ln/src/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,11 @@ pub fn symlink<P1: AsRef<Path>, P2: AsRef<Path>>(src: P1, dst: P2) -> std::io::R
symlink_file(src, dst)
}
}

#[cfg(target_os = "wasi")]
fn symlink<P1: AsRef<Path>, P2: AsRef<Path>>(_src: P1, _dst: P2) -> std::io::Result<()> {
Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
"symlinks not supported on this platform",
))
}
7 changes: 2 additions & 5 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,8 @@ fn rename_symlink_fallback(from: &Path, to: &Path) -> io::Result<()> {
}

#[cfg(target_os = "wasi")]
fn rename_symlink_fallback(from: &Path, to: &Path) -> io::Result<()> {
Err(io::Error::new(
io::ErrorKind::Other,
translate!("mv-error-no-symlink-support"),
))
fn rename_symlink_fallback(_from: &Path, _to: &Path) -> io::Result<()> {
Err(io::Error::other(translate!("mv-error-no-symlink-support")))
}

fn rename_dir_fallback(
Expand Down
2 changes: 2 additions & 0 deletions src/uu/sort/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ impl MergeInput for CompressedTmpMergeInput {
type InnerRead = ChildStdout;

fn finished_reading(self) -> UResult<()> {
// Explicitly close stdout before waiting on the child process.
#[allow(clippy::drop_non_drop)]
drop(self.child_stdout);
check_child_success(self.child, &self.compress_prog)?;
let _ = fs::remove_file(self.path);
Expand Down
12 changes: 7 additions & 5 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ use std::ffi::{OsStr, OsString};
use std::fs::{File, OpenOptions};
use std::hash::{Hash, Hasher};
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
use std::num::{IntErrorKind, NonZero};
use std::num::IntErrorKind;
#[cfg(not(target_os = "wasi"))]
use std::num::NonZero;
use std::ops::Range;
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
Expand Down Expand Up @@ -2124,12 +2126,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
settings.threads = matches
.get_one::<String>(options::PARALLEL)
.map_or_else(|| "0".to_string(), String::from);
let num_threads = match settings.threads.parse::<usize>() {
Ok(0) | Err(_) => std::thread::available_parallelism().map_or(1, NonZero::get),
Ok(n) => n,
};
#[cfg(not(target_os = "wasi"))]
{
let num_threads = match settings.threads.parse::<usize>() {
Ok(0) | Err(_) => std::thread::available_parallelism().map_or(1, NonZero::get),
Ok(n) => n,
};
let _ = rayon::ThreadPoolBuilder::new()
.num_threads(num_threads)
.build_global();
Expand Down
9 changes: 5 additions & 4 deletions src/uu/sort/src/tmp_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

#[cfg(not(target_os = "redox"))]
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
use std::path::Path;
#[cfg(not(target_os = "redox"))]
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
use std::sync::atomic::{AtomicBool, Ordering};
use std::{
fs::File,
Expand All @@ -15,7 +15,7 @@ use std::{

use tempfile::TempDir;
use uucore::error::UResult;
#[cfg(not(target_os = "redox"))]
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
use uucore::{error::USimpleError, show_error, translate};

use crate::{SortError, current_open_fd_count, fd_soft_limit};
Expand Down Expand Up @@ -105,6 +105,7 @@ fn ensure_signal_handler_installed(state: Arc<Mutex<HandlerRegistration>>) -> UR
}

#[cfg(any(target_os = "redox", target_os = "wasi"))]
#[allow(clippy::unnecessary_wraps)]
fn ensure_signal_handler_installed(_state: Arc<Mutex<HandlerRegistration>>) -> UResult<()> {
Ok(())
}
Expand Down Expand Up @@ -184,7 +185,7 @@ impl Drop for TmpDirWrapper {

/// Remove the directory at `path` by deleting its child files and then itself.
/// Errors while deleting child files are ignored.
#[cfg(not(target_os = "redox"))]
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
fn remove_tmp_dir(path: &Path) -> std::io::Result<()> {
if let Ok(read_dir) = std::fs::read_dir(path) {
for file in read_dir.flatten() {
Expand Down
Loading
Loading