1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

Merge branch 'main' into openbsd-utmpx

This commit is contained in:
Sylvestre Ledru 2023-12-16 10:29:16 +01:00 committed by GitHub
commit 1bfac9b25a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 387 additions and 257 deletions

View file

@ -395,14 +395,14 @@ jobs:
--arg multisize "$SIZE_MULTI" \
'{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json
- name: Download the previous individual size result
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v3
with:
workflow: CICD.yml
name: individual-size-result
repo: uutils/coreutils
path: dl
- name: Download the previous size result
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v3
with:
workflow: CICD.yml
name: size-result
@ -439,12 +439,12 @@ jobs:
previous_multisize=$(cat dl/size-result.json | jq -r '.[] | .multisize')
check 'multicall binary' "$multisize" "$previous_multisize" 'size-result.json'
- name: Upload the individual size result
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: individual-size-result
path: individual-size-result.json
- name: Upload the size result
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: size-result
path: size-result.json
@ -473,6 +473,7 @@ jobs:
- { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
- { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true }
- { os: macos-latest , target: aarch64-apple-darwin , features: feat_os_macos , use-cross: use-cross, skip-tests: true} # Hopefully github provides free M1 runners soon...
- { os: macos-latest , target: x86_64-apple-darwin , features: feat_os_macos }
- { os: windows-latest , target: i686-pc-windows-msvc , features: feat_os_windows }
@ -525,7 +526,13 @@ jobs:
i686-*) TARGET_ARCH=i686 ;;
x86_64-*) TARGET_ARCH=x86_64 ;;
esac;
unset TARGET_OS ; case '${{ matrix.job.target }}' in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
unset TARGET_OS
case '${{ matrix.job.target }}' in
*-linux-*) TARGET_OS=linux ;;
*-apple-*) TARGET_OS=macos ;;
*-windows-*) TARGET_OS=windows ;;
*-redox*) TARGET_OS=redox ;;
esac
outputs TARGET_ARCH TARGET_OS
# package name
PKG_suffix=".tar.gz" ; case '${{ matrix.job.target }}' in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
@ -560,8 +567,19 @@ jobs:
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
outputs CARGO_FEATURES_OPTION
# * CARGO_CMD
CARGO_CMD='cross' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) CARGO_CMD='cargo' ;; esac;
CARGO_CMD='cross'
CARGO_CMD_OPTIONS='+${{ env.RUST_MIN_SRV }}'
case '${{ matrix.job.use-cross }}' in
''|0|f|false|n|no)
CARGO_CMD='cargo'
;;
redoxer)
CARGO_CMD='redoxer'
CARGO_CMD_OPTIONS=''
;;
esac
outputs CARGO_CMD
outputs CARGO_CMD_OPTIONS
# ** pass needed environment into `cross` container (iff `cross` not already configured via "Cross.toml")
if [ "${CARGO_CMD}" = 'cross' ] && [ ! -e "Cross.toml" ] ; then
printf "[build.env]\npassthrough = [\"CI\", \"RUST_BACKTRACE\", \"CARGO_TERM_COLOR\"]\n" > Cross.toml
@ -595,6 +613,7 @@ jobs:
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-gnu) 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 ;;
esac
case '${{ matrix.job.os }}' in
macos-latest) brew install coreutils ;; # needed for testing
@ -614,6 +633,10 @@ jobs:
echo "foo" > /home/runner/.plan
;;
esac
- uses: taiki-e/install-action@v2
if: steps.vars.outputs.CARGO_CMD == 'redoxer'
with:
tool: redoxer@0.2.37
- name: Initialize toolchain-dependent workflow variables
id: dep_vars
shell: bash
@ -652,14 +675,14 @@ jobs:
shell: bash
run: |
## Build
${{ steps.vars.outputs.CARGO_CMD }} +${{ env.RUST_MIN_SRV }} build --release \
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release \
--target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
- name: Test
if: matrix.job.skip-tests != true
shell: bash
run: |
## Test
${{ steps.vars.outputs.CARGO_CMD }} +${{ env.RUST_MIN_SRV }} test --target=${{ matrix.job.target }} \
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} test --target=${{ matrix.job.target }} \
${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
env:
RUST_BACKTRACE: "1"
@ -668,12 +691,12 @@ jobs:
shell: bash
run: |
## Test individual utilities
${{ steps.vars.outputs.CARGO_CMD }} +${{ env.RUST_MIN_SRV }} test --target=${{ matrix.job.target }} \
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} test --target=${{ matrix.job.target }} \
${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
env:
RUST_BACKTRACE: "1"
- name: Archive executable artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
@ -784,17 +807,17 @@ jobs:
HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1)
echo "HASH=${HASH}" >> $GITHUB_OUTPUT
- name: Reserve SHA1/ID of 'test-summary'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "${{ steps.summary.outputs.HASH }}"
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Reserve test results summary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-summary
name: busybox-test-summary
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Upload json results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: busybox-result.json
path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }}
@ -872,17 +895,17 @@ jobs:
HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1)
echo "HASH=${HASH}" >> $GITHUB_OUTPUT
- name: Reserve SHA1/ID of 'test-summary'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "${{ steps.summary.outputs.HASH }}"
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Reserve test results summary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-summary
name: toybox-test-summary
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Upload json results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: toybox-result.json
path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }}

View file

@ -77,7 +77,7 @@ jobs:
ref: ${{ steps.vars.outputs.repo_GNU_ref }}
submodules: recursive
- name: Retrieve reference artifacts
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v3
# ref: <https://github.com/dawidd6/action-download-artifact>
continue-on-error: true ## don't break the build for missing reference artifacts (may be expired or just not generated yet)
with:
@ -179,22 +179,22 @@ jobs:
# Compress logs before upload (fails otherwise)
gzip ${{ steps.vars.outputs.TEST_LOGS_GLOB }}
- name: Reserve SHA1/ID of 'test-summary'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "${{ steps.summary.outputs.HASH }}"
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Reserve test results summary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-summary
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Reserve test logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-logs
path: "${{ steps.vars.outputs.TEST_LOGS_GLOB }}"
- name: Upload full json results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: gnu-full-result.json
path: ${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}
@ -288,7 +288,7 @@ jobs:
if test -n "${have_new_failures}" ; then exit -1 ; fi
- name: Upload comparison log (for GnuComment workflow)
if: success() || failure() # run regardless of prior step success/failure
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: comment
path: ${{ steps.vars.outputs.path_reference }}/comment/

98
Cargo.lock generated
View file

@ -781,12 +781,12 @@ dependencies = [
[[package]]
name = "errno"
version = "0.3.5"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
"libc",
"windows-sys 0.48.0",
"windows-sys 0.52.0",
]
[[package]]
@ -1215,9 +1215,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
[[package]]
name = "linux-raw-sys"
version = "0.4.10"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "lock_api"
@ -1600,7 +1600,7 @@ dependencies = [
"hex",
"lazy_static",
"procfs-core",
"rustix 0.38.21",
"rustix 0.38.28",
]
[[package]]
@ -1842,15 +1842,15 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.21"
version = "0.38.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
dependencies = [
"bitflags 2.4.0",
"errno",
"libc",
"linux-raw-sys 0.4.10",
"windows-sys 0.48.0",
"linux-raw-sys 0.4.12",
"windows-sys 0.52.0",
]
[[package]]
@ -2063,7 +2063,7 @@ dependencies = [
"cfg-if",
"fastrand",
"redox_syscall 0.4.0",
"rustix 0.38.21",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -2083,7 +2083,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
dependencies = [
"rustix 0.38.21",
"rustix 0.38.28",
"windows-sys 0.48.0",
]
@ -3403,6 +3403,15 @@ dependencies = [
"windows-targets 0.48.0",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
@ -3433,6 +3442,21 @@ dependencies = [
"windows_x86_64_msvc 0.48.0",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
@ -3445,6 +3469,12 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
@ -3457,6 +3487,12 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
@ -3469,6 +3505,12 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
@ -3481,6 +3523,12 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
@ -3493,6 +3541,12 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
@ -3505,6 +3559,12 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
@ -3518,12 +3578,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "xattr"
version = "1.1.1"
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbc6ab6ec1907d1a901cdbcd2bd4cb9e7d64ce5c9739cbb97d3c391acd8c7fae"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "xattr"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7dae5072fe1f8db8f8d29059189ac175196e410e40ba42d5d4684ae2f750995"
dependencies = [
"libc",
"linux-raw-sys 0.4.12",
"rustix 0.38.28",
]
[[package]]

View file

@ -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.1.1"
xattr = "1.1.3"
zip = { version = "0.6.6", default-features = false, features = ["deflate"] }
hex = "0.4.3"

View file

@ -64,8 +64,12 @@ skip = [
{ name = "rustix", version = "0.37.26" },
# various crates
{ name = "windows-sys", version = "0.45.0" },
# various crates
{ name = "windows-sys", version = "0.48.0" },
# windows-sys
{ name = "windows-targets", version = "0.42.2" },
# windows-sys
{ name = "windows-targets", version = "0.48.0" },
# windows-targets
{ name = "windows_aarch64_gnullvm", version = "0.42.2" },
# windows-targets
@ -80,6 +84,20 @@ skip = [
{ name = "windows_x86_64_gnullvm", version = "0.42.2" },
# windows-targets
{ name = "windows_x86_64_msvc", version = "0.42.2" },
# windows-targets
{ name = "windows_aarch64_gnullvm", version = "0.48.0" },
# windows-targets
{ name = "windows_aarch64_msvc", version = "0.48.0" },
# windows-targets
{ name = "windows_i686_gnu", version = "0.48.0" },
# windows-targets
{ name = "windows_i686_msvc", version = "0.48.0" },
# windows-targets
{ name = "windows_x86_64_gnu", version = "0.48.0" },
# windows-targets
{ name = "windows_x86_64_gnullvm", version = "0.48.0" },
# windows-targets
{ name = "windows_x86_64_msvc", version = "0.48.0" },
# various crates
{ name = "syn", version = "1.0.109" },
# various crates

View file

@ -1,4 +1,4 @@
<!-- spell-checker:ignore pacman pamac nixpkgs openmandriva conda -->
<!-- spell-checker:ignore pacman pamac nixpkgs openmandriva conda winget -->
# Installation
@ -12,7 +12,7 @@ You can also [build uutils from source](build.md).
## Cargo
[![crates.io package](https://repology.org/badge/version-for-repo/crates_io/uutils-coreutils.svg)](https://repology.org/project/uutils-coreutils/versions)
[![crates.io package](https://repology.org/badge/version-for-repo/crates_io/uutils-coreutils.svg)](https://crates.io/crates/coreutils)
```shell
# Linux
@ -65,9 +65,9 @@ emerge -pv sys-apps/uutils-coreutils
### Manjaro
![Manjaro Stable package](https://repology.org/badge/version-for-repo/manjaro_stable/uutils-coreutils.svg)
[![Manjaro Testing package](https://repology.org/badge/version-for-repo/manjaro_testing/uutils-coreutils.svg)](https://repology.org/project/uutils-coreutils/versions)
[![Manjaro Unstable package](https://repology.org/badge/version-for-repo/manjaro_unstable/uutils-coreutils.svg)](https://repology.org/project/uutils-coreutils/versions)
[![Manjaro Stable package](https://repology.org/badge/version-for-repo/manjaro_stable/uutils-coreutils.svg)](https://packages.manjaro.org/?query=uutils-coreutils)
[![Manjaro Testing package](https://repology.org/badge/version-for-repo/manjaro_testing/uutils-coreutils.svg)](https://packages.manjaro.org/?query=uutils-coreutils)
[![Manjaro Unstable package](https://repology.org/badge/version-for-repo/manjaro_unstable/uutils-coreutils.svg)](https://packages.manjaro.org/?query=uutils-coreutils)
```shell
pacman -S uutils-coreutils
@ -77,7 +77,7 @@ pamac install uutils-coreutils
### NixOS
[![nixpkgs unstable package](https://repology.org/badge/version-for-repo/nix_unstable/uutils-coreutils.svg)](https://repology.org/project/uutils-coreutils/versions)
[![nixpkgs unstable package](https://repology.org/badge/version-for-repo/nix_unstable/uutils-coreutils.svg)](https://search.nixos.org/packages?query=uutils-coreutils)
```shell
nix-env -iA nixos.uutils-coreutils
@ -131,9 +131,15 @@ pkg install rust-coreutils
## Windows
### Winget
```shell
winget install uutils.coreutils
```
### Scoop
[![Scoop package](https://repology.org/badge/version-for-repo/scoop/uutils-coreutils.svg)](https://scoop.sh/#/apps?q=uutils-coreutils&s=0&d=1&o=true)
[Scoop package](https://scoop.sh/#/apps?q=uutils-coreutils&s=0&d=1&o=true)
```shell
scoop install uutils-coreutils
@ -146,7 +152,7 @@ scoop install uutils-coreutils
[Conda package](https://anaconda.org/conda-forge/uutils-coreutils)
```
conda install -c conda-forge uutils-coreutils
conda install -c conda-forge uutils-coreutils
```
## Non-standard packages

View file

@ -87,8 +87,7 @@ pub fn parse_base_cmd_args(
usage: &str,
) -> UResult<Config> {
let command = base_app(about, usage);
let arg_list = args.collect_lossy();
Config::from(&command.try_get_matches_from(arg_list)?)
Config::from(&command.try_get_matches_from(args)?)
}
pub fn base_app(about: &'static str, usage: &str) -> Command {

View file

@ -174,8 +174,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let number_mode = if matches.get_flag(options::NUMBER_NONBLANK) {

View file

@ -33,8 +33,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
let default_shell: &'static str = "/bin/sh";

View file

@ -221,8 +221,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let algo_name: &str = match matches.get_one::<String>(options::ALGORITHM) {

View file

@ -145,8 +145,6 @@ fn open_file(name: &str, line_ending: LineEnding) -> io::Result<LineReader> {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED));
let filename1 = matches.get_one::<String>(options::FILE_1).unwrap();

View file

@ -552,8 +552,6 @@ where
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
// get the file to split

View file

@ -1267,8 +1267,6 @@ fn is_fifo(filename: &str) -> bool {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let settings: Settings = Parser::new().parse(

View file

@ -129,8 +129,6 @@ fn generate_ls_colors(fmt: &OutputFmt, sep: &str) -> String {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let files = matches

View file

@ -21,8 +21,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;
let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO));

View file

@ -590,8 +590,6 @@ pub fn div_ceil(a: u64, b: u64) -> u64 {
#[uucore::main]
#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let summarize = matches.get_flag(options::SUMMARIZE);

View file

@ -118,7 +118,6 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<ControlFlow<
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().get_matches_from(args);
let no_newline = matches.get_flag(options::NO_NEWLINE);

View file

@ -98,8 +98,6 @@ pub fn uu_app() -> Command {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
// For expr utility we do not want getopts.
// The following usage should work without escaping hyphens: `expr -15 = 1 + 2 \* \( 3 - -4 \)`
let matches = uu_app().try_get_matches_from(args)?;
@ -108,9 +106,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map(|v| v.into_iter().map(|s| s.as_ref()).collect::<Vec<_>>())
.unwrap_or_default();
let res = AstNode::parse(&token_strings)?.eval()?;
let res: String = AstNode::parse(&token_strings)?.eval()?.eval_as_string();
println!("{res}");
if !is_truthy(&res) {
if !is_truthy(&res.into()) {
return Err(1.into());
}
Ok(())

View file

@ -5,7 +5,8 @@
// spell-checker:ignore (ToDO) ints paren prec multibytes
use num_bigint::BigInt;
use num_bigint::{BigInt, ParseBigIntError};
use num_traits::ToPrimitive;
use onig::{Regex, RegexOptions, Syntax};
use crate::{ExprError, ExprResult};
@ -45,7 +46,7 @@ pub enum StringOp {
}
impl BinOp {
fn eval(&self, left: &AstNode, right: &AstNode) -> ExprResult<String> {
fn eval(&self, left: &AstNode, right: &AstNode) -> ExprResult<NumOrStr> {
match self {
Self::Relation(op) => op.eval(left, right),
Self::Numeric(op) => op.eval(left, right),
@ -55,10 +56,10 @@ impl BinOp {
}
impl RelationOp {
fn eval(&self, a: &AstNode, b: &AstNode) -> ExprResult<String> {
fn eval(&self, a: &AstNode, b: &AstNode) -> ExprResult<NumOrStr> {
let a = a.eval()?;
let b = b.eval()?;
let b = if let (Ok(a), Ok(b)) = (a.parse::<BigInt>(), b.parse::<BigInt>()) {
let b = if let (Ok(a), Ok(b)) = (&a.to_bigint(), &b.to_bigint()) {
match self {
Self::Lt => a < b,
Self::Leq => a <= b,
@ -79,24 +80,18 @@ impl RelationOp {
}
};
if b {
Ok("1".into())
Ok(1.into())
} else {
Ok("0".into())
Ok(0.into())
}
}
}
impl NumericOp {
fn eval(&self, left: &AstNode, right: &AstNode) -> ExprResult<String> {
let a: BigInt = left
.eval()?
.parse()
.map_err(|_| ExprError::NonIntegerArgument)?;
let b: BigInt = right
.eval()?
.parse()
.map_err(|_| ExprError::NonIntegerArgument)?;
Ok(match self {
fn eval(&self, left: &AstNode, right: &AstNode) -> ExprResult<NumOrStr> {
let a = left.eval()?.eval_as_bigint()?;
let b = right.eval()?.eval_as_bigint()?;
Ok(NumOrStr::Num(match self {
Self::Add => a + b,
Self::Sub => a - b,
Self::Mul => a * b,
@ -110,13 +105,12 @@ impl NumericOp {
};
a % b
}
}
.to_string())
}))
}
}
impl StringOp {
fn eval(&self, left: &AstNode, right: &AstNode) -> ExprResult<String> {
fn eval(&self, left: &AstNode, right: &AstNode) -> ExprResult<NumOrStr> {
match self {
Self::Or => {
let left = left.eval()?;
@ -127,23 +121,23 @@ impl StringOp {
if is_truthy(&right) {
return Ok(right);
}
Ok("0".into())
Ok(0.into())
}
Self::And => {
let left = left.eval()?;
if !is_truthy(&left) {
return Ok("0".into());
return Ok(0.into());
}
let right = right.eval()?;
if !is_truthy(&right) {
return Ok("0".into());
return Ok(0.into());
}
Ok(left)
}
Self::Match => {
let left = left.eval()?;
let right = right.eval()?;
let re_string = format!("^{}", &right);
let left = left.eval()?.eval_as_string();
let right = right.eval()?.eval_as_string();
let re_string = format!("^{}", right);
let re = Regex::with_options(
&re_string,
RegexOptions::REGEX_OPTION_NONE,
@ -158,19 +152,20 @@ impl StringOp {
} else {
re.find(&left)
.map_or("0".to_string(), |(start, end)| (end - start).to_string())
})
}
.into())
}
Self::Index => {
let left = left.eval()?;
let right = right.eval()?;
let left = left.eval()?.eval_as_string();
let right = right.eval()?.eval_as_string();
for (current_idx, ch_h) in left.chars().enumerate() {
for ch_n in right.chars() {
for ch_n in right.to_string().chars() {
if ch_n == ch_h {
return Ok((current_idx + 1).to_string());
return Ok((current_idx + 1).into());
}
}
}
Ok("0".to_string())
Ok(0.into())
}
}
}
@ -200,6 +195,55 @@ const PRECEDENCE: &[&[(&str, BinOp)]] = &[
&[(":", BinOp::String(StringOp::Match))],
];
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd)]
pub enum NumOrStr {
Num(BigInt),
Str(String),
}
impl From<usize> for NumOrStr {
fn from(num: usize) -> Self {
Self::Num(BigInt::from(num))
}
}
impl From<BigInt> for NumOrStr {
fn from(num: BigInt) -> Self {
Self::Num(num)
}
}
impl From<String> for NumOrStr {
fn from(str: String) -> Self {
Self::Str(str)
}
}
impl NumOrStr {
pub fn to_bigint(&self) -> Result<BigInt, ParseBigIntError> {
match self {
Self::Num(num) => Ok(num.clone()),
Self::Str(str) => str.parse::<BigInt>(),
}
}
pub fn eval_as_bigint(self) -> ExprResult<BigInt> {
match self {
Self::Num(num) => Ok(num),
Self::Str(str) => str
.parse::<BigInt>()
.map_err(|_| ExprError::NonIntegerArgument),
}
}
pub fn eval_as_string(self) -> String {
match self {
Self::Num(num) => num.to_string(),
Self::Str(str) => str,
}
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum AstNode {
Leaf {
@ -225,9 +269,9 @@ impl AstNode {
Parser::new(input).parse()
}
pub fn eval(&self) -> ExprResult<String> {
pub fn eval(&self) -> ExprResult<NumOrStr> {
match self {
Self::Leaf { value } => Ok(value.into()),
Self::Leaf { value } => Ok(value.to_string().into()),
Self::BinOp {
op_type,
left,
@ -238,7 +282,7 @@ impl AstNode {
pos,
length,
} => {
let string = string.eval()?;
let string: String = string.eval()?.eval_as_string();
// The GNU docs say:
//
@ -247,16 +291,31 @@ impl AstNode {
//
// So we coerce errors into 0 to make that the only case we
// have to care about.
let pos: usize = pos.eval()?.parse().unwrap_or(0);
let length: usize = length.eval()?.parse().unwrap_or(0);
let pos = pos
.eval()?
.eval_as_bigint()
.ok()
.and_then(|n| n.to_usize())
.unwrap_or(0);
let length = length
.eval()?
.eval_as_bigint()
.ok()
.and_then(|n| n.to_usize())
.unwrap_or(0);
let (Some(pos), Some(_)) = (pos.checked_sub(1), length.checked_sub(1)) else {
return Ok(String::new());
return Ok(String::new().into());
};
Ok(string.chars().skip(pos).take(length).collect())
Ok(string
.chars()
.skip(pos)
.take(length)
.collect::<String>()
.into())
}
Self::Length { string } => Ok(string.eval()?.chars().count().to_string()),
Self::Length { string } => Ok(string.eval()?.eval_as_string().chars().count().into()),
}
}
}
@ -399,21 +458,26 @@ impl<'a> Parser<'a> {
/// Determine whether `expr` should evaluate the string as "truthy"
///
/// Truthy strings are either empty or match the regex "-?0+".
pub fn is_truthy(s: &str) -> bool {
// Edge case: `-` followed by nothing is truthy
if s == "-" {
return true;
pub fn is_truthy(s: &NumOrStr) -> bool {
match s {
NumOrStr::Num(num) => num != &BigInt::from(0),
NumOrStr::Str(str) => {
// Edge case: `-` followed by nothing is truthy
if str == "-" {
return true;
}
let mut bytes = str.bytes();
// Empty string is falsy
let Some(first) = bytes.next() else {
return false;
};
let is_zero = (first == b'-' || first == b'0') && bytes.all(|b| b == b'0');
!is_zero
}
}
let mut bytes = s.bytes();
// Empty string is falsy
let Some(first) = bytes.next() else {
return false;
};
let is_zero = (first == b'-' || first == b'0') && bytes.all(|b| b == b'0');
!is_zero
}
#[cfg(test)]

View file

@ -8,8 +8,6 @@
use std::io::{BufWriter, Stdout, Write};
use std::{cmp, i64, mem};
use uucore::crash;
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
use crate::FmtOptions;
@ -363,28 +361,26 @@ fn find_kp_breakpoints<'a, T: Iterator<Item = &'a WordInfo<'a>>>(
}
fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> Vec<(&'a WordInfo<'a>, bool)> {
let mut breakwords = vec![];
// of the active paths, we select the one with the fewest demerits
let mut best_idx = match active.iter().min_by_key(|&&a| paths[a].demerits) {
None => crash!(
1,
"Failed to find a k-p linebreak solution. This should never happen."
),
Some(&s) => s,
};
// now, chase the pointers back through the break list, recording
// the words at which we should break
loop {
let next_best = &paths[best_idx];
match next_best.linebreak {
None => return breakwords,
Some(prev) => {
breakwords.push((prev, next_best.break_before));
best_idx = next_best.prev;
active
.iter()
.min_by_key(|&&a| paths[a].demerits)
.map(|&(mut best_idx)| {
let mut breakwords = vec![];
// now, chase the pointers back through the break list, recording
// the words at which we should break
loop {
let next_best = &paths[best_idx];
match next_best.linebreak {
None => return breakwords,
Some(prev) => {
breakwords.push((prev, next_best.break_before));
best_idx = next_best.prev;
}
}
}
}
}
})
.unwrap_or_default()
}
// "infinite" badness is more like (1+BAD_INFTY)^2 because of how demerits are computed

View file

@ -30,8 +30,6 @@ const USAGE: &str = help_usage!("logname.md");
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let _ = uu_app().try_get_matches_from(args)?;
match get_userlogin() {

View file

@ -1070,6 +1070,7 @@ pub fn uu_app() -> Command {
.about(ABOUT)
.infer_long_args(true)
.disable_help_flag(true)
.args_override_self(true)
.arg(
Arg::new(options::HELP)
.long(options::HELP)
@ -1552,7 +1553,7 @@ pub fn uu_app() -> Command {
.short('h')
.long(options::size::HUMAN_READABLE)
.help("Print human readable file sizes (e.g. 1K 234M 56G).")
.overrides_with(options::size::SI)
.overrides_with_all([options::size::BLOCK_SIZE, options::size::SI])
.action(ArgAction::SetTrue),
)
.arg(
@ -1569,6 +1570,7 @@ pub fn uu_app() -> Command {
Arg::new(options::size::SI)
.long(options::size::SI)
.help("Print human readable file sizes using powers of 1000 instead of 1024.")
.overrides_with_all([options::size::BLOCK_SIZE, options::size::HUMAN_READABLE])
.action(ArgAction::SetTrue),
)
.arg(
@ -1576,7 +1578,8 @@ pub fn uu_app() -> Command {
.long(options::size::BLOCK_SIZE)
.require_equals(true)
.value_name("BLOCK_SIZE")
.help("scale sizes by BLOCK_SIZE when printing them"),
.help("scale sizes by BLOCK_SIZE when printing them")
.overrides_with_all([options::size::SI, options::size::HUMAN_READABLE]),
)
.arg(
Arg::new(options::INODE)

View file

@ -22,8 +22,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
if matches.contains_id(options::CONTEXT) {

View file

@ -68,7 +68,6 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
// Linux-specific options, not implemented
// opts.optflag("Z", "", "set the SELinux security context to default type");
// opts.optopt("", "context", "like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX");

View file

@ -1,57 +0,0 @@
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore (path) osrelease
use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR};
use uucore::mode;
pub const MODE_RW_UGO: mode_t = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
pub fn parse_mode(mode: &str) -> Result<mode_t, String> {
let result = if mode.chars().any(|c| c.is_ascii_digit()) {
mode::parse_numeric(MODE_RW_UGO as u32, mode)
} else {
mode::parse_symbolic(MODE_RW_UGO as u32, mode, true)
};
result.map(|mode| mode as mode_t)
}
#[cfg(test)]
mod test {
/// Test if the program is running under WSL
// ref: <https://github.com/microsoft/WSL/issues/4555> @@ <https://archive.is/dP0bz>
// ToDO: test on WSL2 which likely doesn't need special handling; plan change to `is_wsl_1()` if WSL2 is less needy
pub fn is_wsl() -> bool {
#[cfg(target_os = "linux")]
{
if let Ok(b) = std::fs::read("/proc/sys/kernel/osrelease") {
if let Ok(s) = std::str::from_utf8(&b) {
let a = s.to_ascii_lowercase();
return a.contains("microsoft") || a.contains("wsl");
}
}
}
false
}
#[test]
fn symbolic_modes() {
assert_eq!(super::parse_mode("u+x").unwrap(), 0o766);
assert_eq!(
super::parse_mode("+x").unwrap(),
if is_wsl() { 0o776 } else { 0o777 }
);
assert_eq!(super::parse_mode("a-w").unwrap(), 0o444);
assert_eq!(super::parse_mode("g-r").unwrap(), 0o626);
}
#[test]
fn numeric_modes() {
assert_eq!(super::parse_mode("644").unwrap(), 0o644);
assert_eq!(super::parse_mode("+100").unwrap(), 0o766);
assert_eq!(super::parse_mode("-4").unwrap(), 0o662);
}
}

View file

@ -12,6 +12,7 @@ use uucore::{format_usage, help_about, help_usage};
use std::env;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Display;
use std::io::ErrorKind;
use std::iter;
@ -308,8 +309,7 @@ impl Params {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let args: Vec<_> = args.collect();
let matches = match uu_app().try_get_matches_from(&args) {
Ok(m) => m,
Err(e) => {
@ -333,7 +333,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// If POSIXLY_CORRECT was set, template MUST be the last argument.
if matches.contains_id(ARG_TEMPLATE) {
// Template argument was provided, check if was the last one.
if args.last().unwrap() != &options.template {
if args.last().unwrap() != OsStr::new(&options.template) {
return Err(Box::new(MkTempError::TooManyTemplates));
}
}

View file

@ -87,7 +87,6 @@ impl Options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = match uu_app().try_get_matches_from(args) {
Ok(m) => m,
Err(e) => return Err(e.into()),

View file

@ -178,8 +178,6 @@ pub mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let mut settings = Settings::default();

View file

@ -74,8 +74,6 @@ impl Display for NohupError {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
replace_fds()?;

View file

@ -36,8 +36,6 @@ const POSIX_NAME_MAX: usize = 14;
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
// set working mode

View file

@ -27,7 +27,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().get_matches_from(args);
let format_string = matches

View file

@ -715,8 +715,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let mut input_files: Vec<String> = match &matches.get_many::<String>(options::FILE) {

View file

@ -200,8 +200,6 @@ impl BytesWriter {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
if !matches.contains_id(options::FILE) {

View file

@ -47,8 +47,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let mode = if let Some(args) = matches.get_many::<String>(options::ECHO) {

View file

@ -1029,7 +1029,6 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: &'static str) -> Ar
#[uucore::main]
#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let mut settings = GlobalSettings::default();
let matches = match uu_app().try_get_matches_from(args) {

View file

@ -141,8 +141,6 @@ fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?;

View file

@ -176,8 +176,6 @@ ioctl_write_ptr_bad!(
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let opts = Options::from(&matches)?;

View file

@ -102,8 +102,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let files: Vec<String> = match matches.get_many::<String>(options::FILE) {

View file

@ -33,8 +33,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let before = matches.get_flag(options::BEFORE);

View file

@ -107,8 +107,6 @@ impl Config {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
let config = Config::from(&matches)?;

View file

@ -33,8 +33,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;
let delete_flag = matches.get_flag(options::DELETE);

View file

@ -20,8 +20,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let input = matches

View file

@ -14,8 +14,8 @@ fn test_hostname() {
assert!(ls_default_res.stdout().len() >= ls_domain_res.stdout().len());
}
// FixME: fails for "MacOS" and "freebsd" "failed to lookup address information: Name does not resolve"
#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
// FixME: fails for "MacOS", "freebsd" and "openbsd" "failed to lookup address information: Name does not resolve"
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))]
#[test]
fn test_hostname_ip() {
let result = new_ucmd!().arg("-i").succeeds();

View file

@ -3874,6 +3874,71 @@ fn test_ls_invalid_block_size() {
.stderr_is("ls: invalid --block-size argument 'invalid'\n");
}
#[cfg(all(unix, feature = "dd"))]
#[test]
fn test_ls_block_size_override() {
let scene = TestScenario::new(util_name!());
scene
.ccmd("dd")
.arg("if=/dev/zero")
.arg("of=file")
.arg("bs=1024")
.arg("count=1")
.succeeds();
// --si "wins"
scene
.ucmd()
.arg("-s")
.arg("--block-size=512")
.arg("--si")
.succeeds()
.stdout_contains_line("total 4.1k");
// --block-size "wins"
scene
.ucmd()
.arg("-s")
.arg("--si")
.arg("--block-size=512")
.succeeds()
.stdout_contains_line("total 8");
// --human-readable "wins"
scene
.ucmd()
.arg("-s")
.arg("--block-size=512")
.arg("--human-readable")
.succeeds()
.stdout_contains_line("total 4.0K");
// --block-size "wins"
scene
.ucmd()
.arg("-s")
.arg("--human-readable")
.arg("--block-size=512")
.succeeds()
.stdout_contains_line("total 8");
}
#[test]
fn test_ls_block_size_override_self() {
new_ucmd!()
.arg("--block-size=512")
.arg("--block-size=512")
.succeeds();
new_ucmd!()
.arg("--human-readable")
.arg("--human-readable")
.succeeds();
new_ucmd!().arg("--si").arg("--si").succeeds();
}
#[test]
fn test_ls_hyperlink() {
let scene = TestScenario::new(util_name!());

View file

@ -10,10 +10,20 @@ use std::thread::sleep;
use std::time::Duration;
#[test]
fn test_invalid_arg() {
fn test_mv_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_mv_missing_dest() {
let (at, mut ucmd) = at_and_ucmd!();
let dir = "dir";
at.mkdir(dir);
ucmd.arg(dir).fails();
}
#[test]
fn test_mv_rename_dir() {
let (at, mut ucmd) = at_and_ucmd!();
@ -27,16 +37,6 @@ fn test_mv_rename_dir() {
assert!(at.dir_exists(dir2));
}
#[test]
fn test_mv_fail() {
let (at, mut ucmd) = at_and_ucmd!();
let dir1 = "test_mv_rename_dir";
at.mkdir(dir1);
ucmd.arg(dir1).fails();
}
#[test]
fn test_mv_rename_file() {
let (at, mut ucmd) = at_and_ucmd!();