1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge branch 'main' into kill-group-id

This commit is contained in:
Sylvestre Ledru 2022-05-18 21:12:30 +02:00 committed by GitHub
commit 2a969de2a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
120 changed files with 991 additions and 433 deletions

View file

@ -24,7 +24,7 @@ jobs:
name: Style/cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
style_deps:
@ -43,7 +43,7 @@ jobs:
- { os: macos-latest , features: "feat_Tier1,feat_require_unix,feat_require_unix_utmpx" }
- { os: windows-latest , features: feat_os_windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -101,7 +101,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -165,7 +165,7 @@ jobs:
- { os: macos-latest , features: feat_os_macos }
- { os: windows-latest , features: feat_os_windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -223,7 +223,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -275,7 +275,7 @@ jobs:
# - { os: macos-latest , features: feat_os_macos }
# - { os: windows-latest , features: feat_os_windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -320,7 +320,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -397,7 +397,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Install `rust` toolchain
uses: actions-rs/toolchain@v1
@ -422,7 +422,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Install `rust` toolchain
uses: actions-rs/toolchain@v1
@ -452,7 +452,7 @@ jobs:
- { os: macos-latest , features: feat_os_macos }
- { os: windows-latest , features: feat_os_windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Install `rust` toolchain
uses: actions-rs/toolchain@v1
@ -478,7 +478,7 @@ jobs:
- { os: macos-latest , features: feat_os_macos }
- { os: windows-latest , features: feat_os_windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Install `rust` toolchain
uses: actions-rs/toolchain@v1
@ -502,7 +502,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Install dependencies
shell: bash
@ -534,7 +534,7 @@ jobs:
--arg size "$SIZE" \
--arg multisize "$SIZEMULTI" \
'{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: size-result
path: size-result.json
@ -568,7 +568,7 @@ jobs:
- { os: windows-latest , target: x86_64-pc-windows-gnu , features: feat_os_windows } ## note: requires rust >= 1.43.0 to link correctly
- { os: windows-latest , target: x86_64-pc-windows-msvc , features: feat_os_windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize workflow variables
id: vars
@ -762,7 +762,7 @@ jobs:
args: --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
toolchain: ${{ env.RUST_MIN_SRV }}
- name: Archive executable artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
@ -820,7 +820,7 @@ jobs:
job:
- { os: ubuntu-latest }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Install/setup prerequisites
shell: bash
@ -857,9 +857,9 @@ jobs:
env:
TERMUX: v0.118.0
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: AVD cache
uses: actions/cache@v2
uses: actions/cache@v3
id: avd-cache
with:
path: |
@ -911,11 +911,11 @@ jobs:
env:
mem: 2048
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Prepare, build and test
## spell-checker:ignore (ToDO) sshfs usesh vmactions
uses: vmactions/freebsd-vm@v0.1.5
uses: vmactions/freebsd-vm@v0.1.6
with:
usesh: true
# sync: sshfs
@ -979,7 +979,7 @@ jobs:
- { os: macos-latest , features: macos }
- { os: windows-latest , features: windows }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
# - name: Reattach HEAD ## may be needed for accurate code coverage info
# run: git checkout ${{ github.head_ref }}
@ -1100,7 +1100,7 @@ jobs:
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"
echo ::set-output name=report::${COVERAGE_REPORT_FILE}
- name: Upload coverage results (to Codecov.io)
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
# if: steps.vars.outputs.HAS_CODECOV_TOKEN
with:
# token: ${{ secrets.CODECOV_TOKEN }}

View file

@ -28,7 +28,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize job variables
id: vars
@ -80,7 +80,7 @@ jobs:
## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
RUSTUP_TOOLCHAIN=stable cargo-tree tree --locked --all --no-dev-dependencies --no-indent --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique
- name: Commit any changes (to '${{ env.BRANCH_TARGET }}')
uses: EndBug/add-and-commit@v7
uses: EndBug/add-and-commit@v9
with:
branch: ${{ env.BRANCH_TARGET }}
default_author: github_actions
@ -100,7 +100,7 @@ jobs:
job:
- { os: ubuntu-latest , features: feat_os_unix }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v1
- name: Initialize job variables
id: vars
@ -130,7 +130,7 @@ jobs:
# `cargo fmt` of tests
find tests -name "*.rs" -print0 | xargs -0 cargo fmt --
- name: Commit any changes (to '${{ env.BRANCH_TARGET }}')
uses: EndBug/add-and-commit@v7
uses: EndBug/add-and-commit@v9
with:
branch: ${{ env.BRANCH_TARGET }}
default_author: github_actions

View file

@ -41,11 +41,11 @@ jobs:
TEST_FULL_SUMMARY_FILE='gnu-full-result.json'
outputs SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE
- name: Checkout code (uutil)
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: '${{ steps.vars.outputs.path_UUTILS }}'
- name: Checkout code (GNU coreutils)
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: 'coreutils/coreutils'
path: '${{ steps.vars.outputs.path_GNU }}'
@ -146,22 +146,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@v2
uses: actions/upload-artifact@v3
with:
name: "${{ steps.summary.outputs.HASH }}"
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Reserve test results summary
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-summary
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name: Reserve test logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-logs
path: "${{ steps.vars.outputs.TEST_LOGS_GLOB }}"
- name: Upload full json results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: gnu-full-result.json
path: ${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}
@ -229,11 +229,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code uutil
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: 'uutils'
- name: Checkout GNU coreutils
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: 'coreutils/coreutils'
path: 'gnu'
@ -293,7 +293,7 @@ jobs:
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"
echo ::set-output name=report::${COVERAGE_REPORT_FILE}
- name: Upload coverage results (to Codecov.io)
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
file: ${{ steps.coverage.outputs.report }}
flags: gnutests

236
Cargo.lock generated
View file

@ -256,9 +256,9 @@ dependencies = [
[[package]]
name = "clap"
version = "3.1.15"
version = "3.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85a35a599b11c089a7f49105658d089b8f2cf0882993c17daf6de15285c2c35d"
checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
dependencies = [
"atty",
"bitflags",
@ -273,11 +273,11 @@ dependencies = [
[[package]]
name = "clap_complete"
version = "3.1.3"
version = "3.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7ca9141e27e6ebc52e3c378b0c07f3cea52db46ed1cc5861735fb697b56356"
checksum = "da92e6facd8d73c22745a5d3cbb59bdf8e46e3235c923e516527d8e81eec14a4"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
]
[[package]]
@ -316,7 +316,7 @@ version = "0.0.13"
dependencies = [
"atty",
"chrono",
"clap 3.1.15",
"clap 3.1.18",
"clap_complete",
"conv",
"filetime",
@ -1021,9 +1021,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.125"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libloading"
@ -1055,9 +1055,9 @@ dependencies = [
[[package]]
name = "lscolors"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e9323b3525d4efad2dead1837a105e313253bfdbad1d470994038eededa4d62"
checksum = "88e4434edeec6cd16a7e8e13569af4568a66fcd6d79abd8696db22dd95f920e6"
dependencies = [
"ansi_term",
]
@ -1531,9 +1531,9 @@ dependencies = [
[[package]]
name = "rayon"
version = "1.5.2"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221"
checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d"
dependencies = [
"autocfg",
"crossbeam-deque",
@ -1740,9 +1740,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "signal-hook"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d"
checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d"
dependencies = [
"libc",
"signal-hook-registry",
@ -2028,9 +2028,9 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "unindent"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514672a55d7380da379785a4d70ca8386c8883ff7eaae877be4d2081cebe73d8"
checksum = "52fee519a3e570f7df377a06a1a7775cdbfb7aa460be7e08de2b1f0e69973a44"
[[package]]
name = "unix_socket"
@ -2068,7 +2068,7 @@ checksum = "7cf7d77f457ef8dfa11e4cd5933c5ddb5dc52a94664071951219a97710f0a32b"
name = "uu_arch"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"platform-info",
"uucore",
]
@ -2077,7 +2077,7 @@ dependencies = [
name = "uu_base32"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2093,7 +2093,7 @@ dependencies = [
name = "uu_basename"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2101,7 +2101,7 @@ dependencies = [
name = "uu_basenc"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uu_base32",
"uucore",
]
@ -2111,7 +2111,7 @@ name = "uu_cat"
version = "0.0.13"
dependencies = [
"atty",
"clap 3.1.15",
"clap 3.1.18",
"nix",
"thiserror",
"unix_socket",
@ -2122,7 +2122,7 @@ dependencies = [
name = "uu_chcon"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"fts-sys",
"libc",
"selinux",
@ -2134,7 +2134,7 @@ dependencies = [
name = "uu_chgrp"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2142,7 +2142,7 @@ dependencies = [
name = "uu_chmod"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2151,7 +2151,7 @@ dependencies = [
name = "uu_chown"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2159,7 +2159,7 @@ dependencies = [
name = "uu_chroot"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2167,7 +2167,7 @@ dependencies = [
name = "uu_cksum"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2175,7 +2175,7 @@ dependencies = [
name = "uu_comm"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2183,7 +2183,7 @@ dependencies = [
name = "uu_cp"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"exacl",
"filetime",
"ioctl-sys",
@ -2200,7 +2200,7 @@ dependencies = [
name = "uu_csplit"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"regex",
"thiserror",
"uucore",
@ -2212,7 +2212,7 @@ version = "0.0.13"
dependencies = [
"atty",
"bstr",
"clap 3.1.15",
"clap 3.1.18",
"memchr 2.5.0",
"uucore",
]
@ -2222,7 +2222,7 @@ name = "uu_date"
version = "0.0.13"
dependencies = [
"chrono",
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
"winapi 0.3.9",
@ -2233,7 +2233,7 @@ name = "uu_dd"
version = "0.0.13"
dependencies = [
"byte-unit",
"clap 3.1.15",
"clap 3.1.18",
"gcd",
"libc",
"signal-hook",
@ -2244,7 +2244,7 @@ dependencies = [
name = "uu_df"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"number_prefix",
"unicode-width",
"uucore",
@ -2254,7 +2254,7 @@ dependencies = [
name = "uu_dir"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"selinux",
"uu_ls",
"uucore",
@ -2264,7 +2264,7 @@ dependencies = [
name = "uu_dircolors"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"glob",
"uucore",
]
@ -2273,7 +2273,7 @@ dependencies = [
name = "uu_dirname"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2282,7 +2282,7 @@ name = "uu_du"
version = "0.0.13"
dependencies = [
"chrono",
"clap 3.1.15",
"clap 3.1.18",
"glob",
"uucore",
"winapi 0.3.9",
@ -2292,7 +2292,7 @@ dependencies = [
name = "uu_echo"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2300,7 +2300,7 @@ dependencies = [
name = "uu_env"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"rust-ini",
"uucore",
]
@ -2309,7 +2309,7 @@ dependencies = [
name = "uu_expand"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"unicode-width",
"uucore",
]
@ -2318,7 +2318,7 @@ dependencies = [
name = "uu_expr"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"num-bigint",
"num-traits",
"onig",
@ -2329,7 +2329,7 @@ dependencies = [
name = "uu_factor"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"coz",
"num-traits",
"paste",
@ -2343,7 +2343,7 @@ dependencies = [
name = "uu_false"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2351,7 +2351,7 @@ dependencies = [
name = "uu_fmt"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"unicode-width",
"uucore",
]
@ -2360,7 +2360,7 @@ dependencies = [
name = "uu_fold"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2368,7 +2368,7 @@ dependencies = [
name = "uu_groups"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2378,7 +2378,7 @@ version = "0.0.13"
dependencies = [
"blake2b_simd",
"blake3",
"clap 3.1.15",
"clap 3.1.18",
"digest",
"hex",
"md-5",
@ -2394,7 +2394,7 @@ dependencies = [
name = "uu_head"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"memchr 2.5.0",
"uucore",
]
@ -2403,7 +2403,7 @@ dependencies = [
name = "uu_hostid"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2412,7 +2412,7 @@ dependencies = [
name = "uu_hostname"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"hostname",
"uucore",
"winapi 0.3.9",
@ -2422,7 +2422,7 @@ dependencies = [
name = "uu_id"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"selinux",
"uucore",
]
@ -2431,7 +2431,7 @@ dependencies = [
name = "uu_install"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"file_diff",
"filetime",
"libc",
@ -2443,7 +2443,7 @@ dependencies = [
name = "uu_join"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"memchr 2.5.0",
"uucore",
]
@ -2452,7 +2452,7 @@ dependencies = [
name = "uu_kill"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"nix",
"uucore",
]
@ -2461,7 +2461,7 @@ dependencies = [
name = "uu_link"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2469,7 +2469,7 @@ dependencies = [
name = "uu_ln"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2477,7 +2477,7 @@ dependencies = [
name = "uu_logname"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2488,7 +2488,7 @@ version = "0.0.13"
dependencies = [
"atty",
"chrono",
"clap 3.1.15",
"clap 3.1.18",
"glob",
"lazy_static",
"lscolors",
@ -2505,7 +2505,7 @@ dependencies = [
name = "uu_mkdir"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2513,7 +2513,7 @@ dependencies = [
name = "uu_mkfifo"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2522,7 +2522,7 @@ dependencies = [
name = "uu_mknod"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2531,7 +2531,7 @@ dependencies = [
name = "uu_mktemp"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"rand",
"tempfile",
"uucore",
@ -2542,7 +2542,7 @@ name = "uu_more"
version = "0.0.13"
dependencies = [
"atty",
"clap 3.1.15",
"clap 3.1.18",
"crossterm",
"nix",
"unicode-segmentation",
@ -2554,7 +2554,7 @@ dependencies = [
name = "uu_mv"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"fs_extra",
"uucore",
]
@ -2563,7 +2563,7 @@ dependencies = [
name = "uu_nice"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"nix",
"uucore",
@ -2573,7 +2573,7 @@ dependencies = [
name = "uu_nl"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"regex",
"uucore",
]
@ -2583,7 +2583,7 @@ name = "uu_nohup"
version = "0.0.13"
dependencies = [
"atty",
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2592,7 +2592,7 @@ dependencies = [
name = "uu_nproc"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"num_cpus",
"uucore",
@ -2602,7 +2602,7 @@ dependencies = [
name = "uu_numfmt"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2611,7 +2611,7 @@ name = "uu_od"
version = "0.0.13"
dependencies = [
"byteorder",
"clap 3.1.15",
"clap 3.1.18",
"half",
"uucore",
]
@ -2620,7 +2620,7 @@ dependencies = [
name = "uu_paste"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2628,7 +2628,7 @@ dependencies = [
name = "uu_pathchk"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2637,7 +2637,7 @@ dependencies = [
name = "uu_pinky"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2646,7 +2646,7 @@ name = "uu_pr"
version = "0.0.13"
dependencies = [
"chrono",
"clap 3.1.15",
"clap 3.1.18",
"itertools",
"quick-error",
"regex",
@ -2657,7 +2657,7 @@ dependencies = [
name = "uu_printenv"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2665,7 +2665,7 @@ dependencies = [
name = "uu_printf"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2673,7 +2673,7 @@ dependencies = [
name = "uu_ptx"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"regex",
"uucore",
]
@ -2682,7 +2682,7 @@ dependencies = [
name = "uu_pwd"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2690,7 +2690,7 @@ dependencies = [
name = "uu_readlink"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2698,7 +2698,7 @@ dependencies = [
name = "uu_realpath"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2706,7 +2706,7 @@ dependencies = [
name = "uu_relpath"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2714,7 +2714,7 @@ dependencies = [
name = "uu_rm"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"remove_dir_all 0.7.0",
"uucore",
"walkdir",
@ -2725,7 +2725,7 @@ dependencies = [
name = "uu_rmdir"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2734,7 +2734,7 @@ dependencies = [
name = "uu_runcon"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"selinux",
"thiserror",
@ -2746,7 +2746,7 @@ name = "uu_seq"
version = "0.0.13"
dependencies = [
"bigdecimal",
"clap 3.1.15",
"clap 3.1.18",
"num-bigint",
"num-traits",
"uucore",
@ -2756,7 +2756,7 @@ dependencies = [
name = "uu_shred"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"rand",
"uucore",
]
@ -2765,7 +2765,7 @@ dependencies = [
name = "uu_shuf"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"rand",
"rand_core",
"uucore",
@ -2775,7 +2775,7 @@ dependencies = [
name = "uu_sleep"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2784,7 +2784,7 @@ name = "uu_sort"
version = "0.0.13"
dependencies = [
"binary-heap-plus",
"clap 3.1.15",
"clap 3.1.18",
"compare",
"ctrlc",
"fnv",
@ -2802,7 +2802,7 @@ dependencies = [
name = "uu_split"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"memchr 2.5.0",
"uucore",
]
@ -2811,7 +2811,7 @@ dependencies = [
name = "uu_stat"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2819,7 +2819,7 @@ dependencies = [
name = "uu_stdbuf"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"tempfile",
"uu_stdbuf_libstdbuf",
"uucore",
@ -2839,7 +2839,7 @@ dependencies = [
name = "uu_sum"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2847,7 +2847,7 @@ dependencies = [
name = "uu_sync"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
"winapi 0.3.9",
@ -2857,7 +2857,7 @@ dependencies = [
name = "uu_tac"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"memchr 2.5.0",
"memmap2",
"regex",
@ -2868,7 +2868,7 @@ dependencies = [
name = "uu_tail"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"nix",
"uucore",
@ -2879,7 +2879,7 @@ dependencies = [
name = "uu_tee"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"retain_mut",
"uucore",
@ -2889,7 +2889,7 @@ dependencies = [
name = "uu_test"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"redox_syscall",
"uucore",
@ -2899,7 +2899,7 @@ dependencies = [
name = "uu_timeout"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"nix",
"uucore",
@ -2909,7 +2909,7 @@ dependencies = [
name = "uu_touch"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"filetime",
"time 0.3.9",
"uucore",
@ -2920,7 +2920,7 @@ dependencies = [
name = "uu_tr"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"nom",
"uucore",
]
@ -2929,7 +2929,7 @@ dependencies = [
name = "uu_true"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2937,7 +2937,7 @@ dependencies = [
name = "uu_truncate"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2945,7 +2945,7 @@ dependencies = [
name = "uu_tsort"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -2954,7 +2954,7 @@ name = "uu_tty"
version = "0.0.13"
dependencies = [
"atty",
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
]
@ -2963,7 +2963,7 @@ dependencies = [
name = "uu_uname"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"platform-info",
"uucore",
]
@ -2972,7 +2972,7 @@ dependencies = [
name = "uu_unexpand"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"unicode-width",
"uucore",
]
@ -2981,7 +2981,7 @@ dependencies = [
name = "uu_uniq"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"strum",
"strum_macros",
"uucore",
@ -2991,7 +2991,7 @@ dependencies = [
name = "uu_unlink"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -3000,7 +3000,7 @@ name = "uu_uptime"
version = "0.0.13"
dependencies = [
"chrono",
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -3008,7 +3008,7 @@ dependencies = [
name = "uu_users"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -3016,7 +3016,7 @@ dependencies = [
name = "uu_vdir"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"selinux",
"uu_ls",
"uucore",
@ -3027,7 +3027,7 @@ name = "uu_wc"
version = "0.0.13"
dependencies = [
"bytecount",
"clap 3.1.15",
"clap 3.1.18",
"libc",
"nix",
"unicode-width",
@ -3039,7 +3039,7 @@ dependencies = [
name = "uu_who"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"uucore",
]
@ -3047,7 +3047,7 @@ dependencies = [
name = "uu_whoami"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"libc",
"uucore",
"winapi 0.3.9",
@ -3057,7 +3057,7 @@ dependencies = [
name = "uu_yes"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"nix",
"uucore",
]
@ -3066,7 +3066,7 @@ dependencies = [
name = "uucore"
version = "0.0.13"
dependencies = [
"clap 3.1.15",
"clap 3.1.18",
"data-encoding",
"data-encoding-macro",
"dns-lookup",

View file

@ -123,7 +123,12 @@ pub fn base_app<'a>(about: &'a str, usage: &'a str) -> Command<'a> {
)
// "multiple" arguments are used to check whether there is more than one
// file passed in.
.arg(Arg::new(options::FILE).index(1).multiple_occurrences(true))
.arg(
Arg::new(options::FILE)
.index(1)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}
pub fn get_input<'a>(config: &Config, stdin_ref: &'a Stdin) -> UResult<Box<dyn Read + 'a>> {

View file

@ -102,6 +102,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::NAME)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath)
.hide(true),
)
.arg(

View file

@ -249,7 +249,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::SHOW_ALL)

View file

@ -197,6 +197,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::REFERENCE)
.takes_value(true)
.value_name("RFILE")
.value_hint(clap::ValueHint::FilePath)
.conflicts_with_all(&[options::USER, options::ROLE, options::TYPE, options::RANGE])
.help(
"Use security context of RFILE, rather than specifying \
@ -210,6 +211,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::USER)
.takes_value(true)
.value_name("USER")
.value_hint(clap::ValueHint::Username)
.help("Set user USER in the target security context.")
.allow_invalid_utf8(true),
)
@ -294,6 +296,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new("FILE")
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath)
.min_values(1)
.allow_invalid_utf8(true),
)

View file

@ -113,6 +113,7 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::REFERENCE)
.long(options::REFERENCE)
.value_name("RFILE")
.value_hint(clap::ValueHint::FilePath)
.help("use RFILE's group rather than specifying GROUP values")
.takes_value(true)
.multiple_occurrences(false),

View file

@ -16,7 +16,7 @@ path = "src/chmod.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] }
[[bin]]

View file

@ -157,6 +157,7 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::REFERENCE)
.long("reference")
.takes_value(true)
.value_hint(clap::ValueHint::FilePath)
.help("use RFILE's mode instead of MODE values"),
)
.arg(
@ -170,7 +171,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.required_unless_present(options::MODE)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -134,6 +134,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::REFERENCE)
.help("use RFILE's owner and group rather than specifying OWNER:GROUP values")
.value_name("RFILE")
.value_hint(clap::ValueHint::FilePath)
.min_values(1),
)
.arg(
@ -167,17 +168,18 @@ pub fn uu_app<'a>() -> Command<'a> {
)
}
/// Parse the username and groupname
/// Parse the owner/group specifier string into a user ID and a group ID.
///
/// In theory, it should be username:groupname
/// but ...
/// it can user.name:groupname
/// or username.groupname
/// The `spec` can be of the form:
///
/// # Arguments
/// * `"owner:group"`,
/// * `"owner"`,
/// * `":group"`,
///
/// * `spec` - The input from the user
/// * `sep` - Should be ':' or '.'
/// and the owner or group can be specified either as an ID or a
/// name. The `sep` argument specifies which character to use as a
/// separator between the owner and group; calling code should set
/// this to `':'`.
fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
assert!(['.', ':'].contains(&sep));
let mut args = spec.splitn(2, sep);
@ -197,10 +199,17 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
// So, try to parse it this way
return parse_spec(spec, '.');
} else {
// It's possible that the `user` string contains a
// numeric user ID, in which case, we respect that.
match user.parse() {
Ok(uid) => uid,
Err(_) => {
return Err(USimpleError::new(
1,
format!("invalid user: {}", spec.quote()),
));
))
}
}
}
}
})
@ -208,11 +217,18 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
None
};
let gid = if !group.is_empty() {
Some(
Group::locate(group)
.map_err(|_| USimpleError::new(1, format!("invalid group: {}", spec.quote())))?
.gid,
)
Some(match Group::locate(group) {
Ok(g) => g.gid,
Err(_) => match group.parse() {
Ok(gid) => gid,
Err(_) => {
return Err(USimpleError::new(
1,
format!("invalid group: {}", spec.quote()),
));
}
},
})
} else {
None
};
@ -231,4 +247,17 @@ mod test {
assert!(format!("{}", parse_spec("::", ':').err().unwrap()).starts_with("invalid group: "));
assert!(format!("{}", parse_spec("..", ':').err().unwrap()).starts_with("invalid group: "));
}
/// Test for parsing IDs that don't correspond to a named user or group.
#[test]
fn test_parse_spec_nameless_ids() {
// This assumes that there is no named user with ID 12345.
assert!(matches!(parse_spec("12345", ':'), Ok((Some(12345), None))));
// This assumes that there is no named group with ID 54321.
assert!(matches!(parse_spec(":54321", ':'), Ok((None, Some(54321)))));
assert!(matches!(
parse_spec("12345:54321", ':'),
Ok((Some(12345), Some(54321)))
));
}
}

View file

@ -102,6 +102,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.infer_long_args(true)
.arg(
Arg::new(options::NEWROOT)
.value_hint(clap::ValueHint::DirPath)
.hide(true)
.required(true)
.index(1),
@ -139,6 +140,7 @@ pub fn uu_app<'a>() -> Command<'a> {
)
.arg(
Arg::new(options::COMMAND)
.value_hint(clap::ValueHint::CommandName)
.hide(true)
.multiple_occurrences(true)
.index(2),

View file

@ -150,6 +150,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -173,6 +173,14 @@ pub fn uu_app<'a>() -> Command<'a> {
.default_value(options::DELIMITER_DEFAULT)
.hide_default_value(true),
)
.arg(Arg::new(options::FILE_1).required(true))
.arg(Arg::new(options::FILE_2).required(true))
.arg(
Arg::new(options::FILE_1)
.required(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::FILE_2)
.required(true)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -21,7 +21,7 @@ path = "src/cp.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
filetime = "0.2"
libc = "0.2.125"
libc = "0.2.126"
quick-error = "2.0.1"
selinux = { version="0.2", optional=true }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }

View file

@ -314,6 +314,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.conflicts_with(options::NO_TARGET_DIRECTORY)
.long(options::TARGET_DIRECTORY)
.value_name(options::TARGET_DIRECTORY)
.value_hint(clap::ValueHint::DirPath)
.takes_value(true)
.validator(|s| {
if Path::new(s).is_dir() {
@ -464,7 +465,8 @@ pub fn uu_app<'a>() -> Command<'a> {
// END TODO
.arg(Arg::new(options::PATHS)
.multiple_occurrences(true))
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath))
}
#[uucore::main]

View file

@ -797,7 +797,12 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::ELIDE_EMPTY_FILES)
.help("remove empty output files"),
)
.arg(Arg::new(options::FILE).hide(true).required(true))
.arg(
Arg::new(options::FILE)
.hide(true)
.required(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::PATTERN)
.hide(true)

View file

@ -615,5 +615,6 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath)
)
}

View file

@ -272,6 +272,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.short('f')
.long(OPT_FILE)
.takes_value(true)
.value_hint(clap::ValueHint::FilePath)
.help("like --date; once for each line of DATEFILE"),
)
.arg(
@ -303,6 +304,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.short('r')
.long(OPT_REFERENCE)
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath)
.help("display the last modification time of FILE"),
)
.arg(

View file

@ -22,7 +22,7 @@ libc = "0.2"
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
signal-hook = "0.3.9"
signal-hook = "0.3.14"
[[bin]]
name = "dd"

View file

@ -742,6 +742,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::INFILE)
.overrides_with(options::INFILE)
.takes_value(true)
.value_hint(clap::ValueHint::FilePath)
.require_equals(true)
.value_name("FILE")
.help("(alternatively if=FILE) specifies the file used for input. When not specified, stdin is used instead")
@ -751,6 +752,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::OUTFILE)
.overrides_with(options::OUTFILE)
.takes_value(true)
.value_hint(clap::ValueHint::FilePath)
.require_equals(true)
.value_name("FILE")
.help("(alternatively of=FILE) specifies the file used for output. When not specified, stdout is used instead")

View file

@ -388,7 +388,7 @@ fn parse_bytes_no_x(s: &str) -> Result<u64, ParseError> {
let (num, multiplier) = match (s.find('c'), s.rfind('w'), s.rfind('b')) {
(None, None, None) => match uucore::parse_size::parse_size(s) {
Ok(n) => (n, 1),
Err(ParseSizeError::ParseFailure(s)) => {
Err(ParseSizeError::InvalidSuffix(s)) | Err(ParseSizeError::ParseFailure(s)) => {
return Err(ParseError::MultiplierStringParseFailure(s))
}
Err(ParseSizeError::SizeTooBig(s)) => {

View file

@ -7,7 +7,10 @@ use crate::OPT_BLOCKSIZE;
use clap::ArgMatches;
use std::{env, fmt};
use uucore::parse_size::{parse_size, ParseSizeError};
use uucore::{
display::Quotable,
parse_size::{parse_size, ParseSizeError},
};
/// The first ten powers of 1024.
const IEC_BASES: [u128; 10] = [
@ -167,6 +170,15 @@ pub(crate) enum BlockSize {
Bytes(u64),
}
impl BlockSize {
/// Returns the associated value
pub(crate) fn as_u64(&self) -> u64 {
match *self {
Self::Bytes(n) => n,
}
}
}
impl Default for BlockSize {
fn default() -> Self {
if env::var("POSIXLY_CORRECT").is_ok() {
@ -180,7 +192,13 @@ impl Default for BlockSize {
pub(crate) fn block_size_from_matches(matches: &ArgMatches) -> Result<BlockSize, ParseSizeError> {
if matches.is_present(OPT_BLOCKSIZE) {
let s = matches.value_of(OPT_BLOCKSIZE).unwrap();
Ok(BlockSize::Bytes(parse_size(s)?))
let bytes = parse_size(s)?;
if bytes > 0 {
Ok(BlockSize::Bytes(bytes))
} else {
Err(ParseSizeError::ParseFailure(format!("{}", s.quote())))
}
} else {
Ok(Default::default())
}

View file

@ -12,6 +12,7 @@ mod filesystem;
mod table;
use blocks::{HumanReadable, SizeFormat};
use table::HeaderMode;
use uucore::display::Quotable;
use uucore::error::{UError, UResult, USimpleError};
use uucore::fsext::{read_fs_list, MountInfo};
@ -72,6 +73,7 @@ struct Options {
show_all_fs: bool,
size_format: SizeFormat,
block_size: BlockSize,
header_mode: HeaderMode,
/// Optional list of filesystem types to include in the output table.
///
@ -99,6 +101,7 @@ impl Default for Options {
show_all_fs: Default::default(),
block_size: Default::default(),
size_format: Default::default(),
header_mode: Default::default(),
include: Default::default(),
exclude: Default::default(),
show_total: Default::default(),
@ -118,6 +121,7 @@ impl Default for Options {
enum OptionsError {
BlockSizeTooLarge(String),
InvalidBlockSize(String),
InvalidSuffix(String),
/// An error getting the columns to display in the output table.
ColumnError(ColumnError),
@ -136,6 +140,9 @@ impl fmt::Display for OptionsError {
// TODO This needs to vary based on whether `--block-size`
// or `-B` were provided.
Self::InvalidBlockSize(s) => write!(f, "invalid --block-size argument {}", s),
// TODO This needs to vary based on whether `--block-size`
// or `-B` were provided.
Self::InvalidSuffix(s) => write!(f, "invalid suffix in --block-size argument {}", s),
Self::ColumnError(ColumnError::MultipleColumns(s)) => write!(
f,
"option --output: field {} used more than once",
@ -171,11 +178,27 @@ impl Options {
show_local_fs: matches.is_present(OPT_LOCAL),
show_all_fs: matches.is_present(OPT_ALL),
block_size: block_size_from_matches(matches).map_err(|e| match e {
ParseSizeError::InvalidSuffix(s) => OptionsError::InvalidSuffix(s),
ParseSizeError::SizeTooBig(_) => OptionsError::BlockSizeTooLarge(
matches.value_of(OPT_BLOCKSIZE).unwrap().to_string(),
),
ParseSizeError::ParseFailure(s) => OptionsError::InvalidBlockSize(s),
})?,
header_mode: {
if matches.is_present(OPT_HUMAN_READABLE_BINARY)
|| matches.is_present(OPT_HUMAN_READABLE_DECIMAL)
{
HeaderMode::HumanReadable
} else if matches.is_present(OPT_PORTABILITY) {
HeaderMode::PosixPortability
// is_present() doesn't work here, it always returns true because OPT_OUTPUT has
// default values and hence is always present
} else if matches.occurrences_of(OPT_OUTPUT) > 0 {
HeaderMode::Output
} else {
HeaderMode::Default
}
},
size_format: {
if matches.is_present(OPT_HUMAN_READABLE_BINARY) {
SizeFormat::HumanReadable(HumanReadable::Binary)
@ -565,7 +588,11 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.help("limit listing to file systems not of type TYPE"),
)
.arg(Arg::new(OPT_PATHS).multiple_occurrences(true))
.arg(
Arg::new(OPT_PATHS)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath),
)
}
#[cfg(test)]

View file

@ -233,7 +233,7 @@ impl<'a> RowFormatter<'a> {
SizeFormat::HumanReadable(h) => self.scaled_human_readable(size, h),
SizeFormat::StaticBlockSize => {
let BlockSize::Bytes(d) = self.options.block_size;
(size / d).to_string()
(size as f64 / d as f64).ceil().to_string()
}
}
}
@ -289,6 +289,23 @@ impl<'a> RowFormatter<'a> {
}
}
/// A HeaderMode defines what header labels should be shown.
pub(crate) enum HeaderMode {
Default,
// the user used -h or -H
HumanReadable,
// the user used -P
PosixPortability,
// the user used --output
Output,
}
impl Default for HeaderMode {
fn default() -> Self {
Self::Default
}
}
/// The data of the header row.
struct Header {}
@ -302,15 +319,22 @@ impl Header {
for column in &options.columns {
let header = match column {
Column::Source => String::from("Filesystem"),
Column::Size => match options.size_format {
SizeFormat::HumanReadable(_) => String::from("Size"),
SizeFormat::StaticBlockSize => {
format!("{}-blocks", options.block_size)
Column::Size => match options.header_mode {
HeaderMode::HumanReadable => String::from("Size"),
HeaderMode::PosixPortability => {
format!("{}-blocks", options.block_size.as_u64())
}
_ => format!("{}-blocks", options.block_size),
},
Column::Used => String::from("Used"),
Column::Avail => String::from("Available"),
Column::Pcent => String::from("Use%"),
Column::Avail => match options.header_mode {
HeaderMode::HumanReadable | HeaderMode::Output => String::from("Avail"),
_ => String::from("Available"),
},
Column::Pcent => match options.header_mode {
HeaderMode::PosixPortability => String::from("Capacity"),
_ => String::from("Use%"),
},
Column::Target => String::from("Mounted on"),
Column::Itotal => String::from("Inodes"),
Column::Iused => String::from("IUsed"),
@ -428,7 +452,7 @@ mod tests {
use crate::blocks::{HumanReadable, SizeFormat};
use crate::columns::Column;
use crate::table::{Header, Row, RowFormatter};
use crate::table::{Header, HeaderMode, Row, RowFormatter};
use crate::{BlockSize, Options};
const COLUMNS_WITH_FS_TYPE: [Column; 7] = [
@ -548,37 +572,49 @@ mod tests {
}
#[test]
fn test_header_with_human_readable_binary() {
fn test_human_readable_header() {
let options = Options {
size_format: SizeFormat::HumanReadable(HumanReadable::Binary),
header_mode: HeaderMode::HumanReadable,
..Default::default()
};
assert_eq!(
Header::get_headers(&options),
vec!("Filesystem", "Size", "Used", "Avail", "Use%", "Mounted on")
);
}
#[test]
fn test_posix_portability_header() {
let options = Options {
header_mode: HeaderMode::PosixPortability,
..Default::default()
};
assert_eq!(
Header::get_headers(&options),
vec!(
"Filesystem",
"Size",
"1024-blocks",
"Used",
"Available",
"Use%",
"Capacity",
"Mounted on"
)
);
}
#[test]
fn test_header_with_human_readable_si() {
fn test_output_header() {
let options = Options {
size_format: SizeFormat::HumanReadable(HumanReadable::Decimal),
header_mode: HeaderMode::Output,
..Default::default()
};
assert_eq!(
Header::get_headers(&options),
vec!(
"Filesystem",
"Size",
"1K-blocks",
"Used",
"Available",
"Avail",
"Use%",
"Mounted on"
)
@ -757,4 +793,28 @@ mod tests {
let fmt = RowFormatter::new(&row, &options);
assert_eq!(fmt.get_values(), vec!("26%"));
}
#[test]
fn test_row_formatter_with_round_up_byte_values() {
fn get_formatted_values(bytes: u64, bytes_used: u64, bytes_avail: u64) -> Vec<String> {
let options = Options {
block_size: BlockSize::Bytes(1000),
columns: vec![Column::Size, Column::Used, Column::Avail],
..Default::default()
};
let row = Row {
bytes,
bytes_used,
bytes_avail,
..Default::default()
};
RowFormatter::new(&row, &options).get_values()
}
assert_eq!(get_formatted_values(100, 100, 0), vec!("1", "1", "0"));
assert_eq!(get_formatted_values(100, 99, 1), vec!("1", "1", "1"));
assert_eq!(get_formatted_values(1000, 1000, 0), vec!("1", "1", "0"));
assert_eq!(get_formatted_values(1001, 1000, 1), vec!("2", "1", "1"));
}
}

View file

@ -187,6 +187,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.value_hint(clap::ValueHint::FilePath)
.multiple_occurrences(true),
)
}

View file

@ -88,5 +88,10 @@ pub fn uu_app<'a>() -> Command<'a> {
.short('z')
.help("separate output with NUL rather than newline"),
)
.arg(Arg::new(options::DIR).hide(true).multiple_occurrences(true))
.arg(
Arg::new(options::DIR)
.hide(true)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -884,6 +884,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.short('X')
.long("exclude-from")
.value_name("FILE")
.value_hint(clap::ValueHint::FilePath)
.help("exclude files that match any pattern in FILE")
.multiple_occurrences(true)
@ -913,6 +914,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.value_hint(clap::ValueHint::AnyPath)
.multiple_occurrences(true)
)
}
@ -951,8 +953,10 @@ impl Threshold {
fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String {
// NOTE:
// GNU's du echos affected flag, -B or --block-size (-t or --threshold), depending user's selection
// GNU's du does distinguish between "invalid (suffix in) argument"
match error {
ParseSizeError::InvalidSuffix(_) => {
format!("invalid suffix in --{} argument {}", option, s.quote())
}
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument {}", option, s.quote()),
ParseSizeError::SizeTooBig(_) => format!("--{} argument {} too large", option, s.quote()),
}

View file

@ -144,6 +144,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.takes_value(true)
.number_of_values(1)
.value_name("DIR")
.value_hint(clap::ValueHint::DirPath)
.help("change working directory to DIR"))
.arg(Arg::new("null")
.short('0')
@ -156,6 +157,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.takes_value(true)
.number_of_values(1)
.value_name("PATH")
.value_hint(clap::ValueHint::FilePath)
.multiple_occurrences(true)
.help("read and set variables from a \".env\"-style configuration file (prior to any \
unset and/or set)"))

View file

@ -207,6 +207,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.hide(true)
.takes_value(true)
.value_hint(clap::ValueHint::FilePath)
)
}

View file

@ -344,6 +344,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true),
.takes_value(true)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -99,14 +99,15 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
for (i, arg) in args.iter().enumerate() {
let slice = &arg;
if slice.starts_with('-') && slice.chars().nth(1).map_or(false, |c| c.is_digit(10)) {
if slice.starts_with('-') && slice.chars().nth(1).map_or(false, |c| c.is_ascii_digit()) {
let mut v = args.to_vec();
v.remove(i);
return (v, Some(slice[1..].to_owned()));

View file

@ -112,6 +112,7 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::USERS)
.multiple_occurrences(true)
.takes_value(true)
.value_name(options::USERS),
.value_name(options::USERS)
.value_hint(clap::ValueHint::Username),
)
}

View file

@ -423,6 +423,7 @@ pub fn uu_app_common<'a>() -> Command<'a> {
.index(1)
.multiple_occurrences(true)
.value_name("FILE")
.value_hint(clap::ValueHint::FilePath)
.allow_invalid_utf8(true),
)
}

View file

@ -107,7 +107,11 @@ pub fn uu_app<'a>() -> Command<'a> {
.help("line delimiter is NUL, not newline")
.overrides_with(options::ZERO_NAME),
)
.arg(Arg::new(options::FILES_NAME).multiple_occurrences(true))
.arg(
Arg::new(options::FILES_NAME)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}
#[derive(Debug, PartialEq)]

View file

@ -20,7 +20,7 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
let mut has_num = false;
let mut last_char = 0 as char;
for (n, c) in &mut chars {
if c.is_digit(10) {
if c.is_ascii_digit() {
has_num = true;
num_end = n;
} else {

View file

@ -16,7 +16,7 @@ path = "src/hostid.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[[bin]]

View file

@ -105,7 +105,11 @@ pub fn uu_app<'a>() -> Command<'a> {
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
.help("Display the short hostname (the portion before the first dot) if possible"),
)
.arg(Arg::new(OPT_HOST).allow_invalid_utf8(true))
.arg(
Arg::new(OPT_HOST)
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::Hostname),
)
}
fn display_hostname(matches: &ArgMatches) -> UResult<()> {

View file

@ -443,7 +443,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::ARG_USERS)
.multiple_occurrences(true)
.takes_value(true)
.value_name(options::ARG_USERS),
.value_name(options::ARG_USERS)
.value_hint(clap::ValueHint::Username),
)
}

View file

@ -248,6 +248,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.help("set ownership (super-user only)")
.value_name("OWNER")
.takes_value(true)
.value_hint(clap::ValueHint::Username)
)
.arg(
Arg::new(OPT_PRESERVE_TIMESTAMPS)
@ -266,6 +267,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(OPT_STRIP_PROGRAM)
.help("program used to strip binaries (no action Windows)")
.value_name("PROGRAM")
.value_hint(clap::ValueHint::CommandName)
)
.arg(
backup_control::arguments::suffix()
@ -277,6 +279,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(OPT_TARGET_DIRECTORY)
.help("move all SOURCE arguments into DIRECTORY")
.value_name("DIRECTORY")
.value_hint(clap::ValueHint::DirPath)
)
.arg(
// TODO implement flag
@ -307,7 +310,13 @@ pub fn uu_app<'a>() -> Command<'a> {
.help("(unimplemented) set security context of files and directories")
.value_name("CONTEXT")
)
.arg(Arg::new(ARG_FILES).multiple_occurrences(true).takes_value(true).min_values(1))
.arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true)
.min_values(1)
.value_hint(clap::ValueHint::AnyPath)
)
}
/// Check for unimplemented command line arguments.

View file

@ -801,12 +801,14 @@ FILENUM is 1 or 2, corresponding to FILE1 or FILE2",
Arg::new("file1")
.required(true)
.value_name("FILE1")
.value_hint(clap::ValueHint::FilePath)
.hide(true),
)
.arg(
Arg::new("file2")
.required(true)
.value_name("FILE2")
.value_hint(clap::ValueHint::FilePath)
.hide(true),
)
}

View file

@ -46,6 +46,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.min_values(2)
.max_values(2)
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath)
.allow_invalid_utf8(true),
)
}

View file

@ -232,6 +232,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::TARGET_DIRECTORY)
.help("specify the DIRECTORY in which to create the links")
.value_name("DIRECTORY")
.value_hint(clap::ValueHint::DirPath)
.conflicts_with(options::NO_TARGET_DIRECTORY),
)
.arg(
@ -257,6 +258,7 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath)
.required(true)
.min_values(1),
)

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/logname.rs"
[dependencies]
libc = "0.2.125"
libc = "0.2.126"
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }

View file

@ -22,7 +22,7 @@ number_prefix = "0.4"
term_grid = "0.1.5"
termsize = "0.1.6"
glob = "0.3.0"
lscolors = { version = "0.9.0", features = ["ansi_term"] }
lscolors = { version = "0.10.0", features = ["ansi_term"] }
uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore", features = ["entries", "fs"] }
once_cell = "1.10.0"
atty = "0.2"

View file

@ -28,7 +28,7 @@ use std::{
cmp::Reverse,
error::Error,
ffi::{OsStr, OsString},
fmt::Display,
fmt::{Display, Write as FmtWrite},
fs::{self, DirEntry, FileType, Metadata, ReadDir},
io::{stdout, BufWriter, ErrorKind, Stdout, Write},
path::{Path, PathBuf},
@ -1402,7 +1402,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::PATHS)
.multiple_occurrences(true)
.takes_value(true)
.allow_invalid_utf8(true),
.value_hint(clap::ValueHint::AnyPath)
.allow_invalid_utf8(true)
)
.after_help(
"The TIME_STYLE argument can be full-iso, long-iso, iso. \
@ -1825,7 +1826,7 @@ fn display_additional_leading_info(
} else {
"?".to_owned()
};
result.push_str(&format!("{} ", pad_left(&i, padding.inode)));
write!(result, "{} ", pad_left(&i, padding.inode)).unwrap();
}
}
@ -1835,7 +1836,7 @@ fn display_additional_leading_info(
} else {
"?".to_owned()
};
result.push_str(&format!("{} ", pad_left(&s, padding.block_size),));
write!(result, "{} ", pad_left(&s, padding.block_size)).unwrap();
}
Ok(result)
}

View file

@ -137,7 +137,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.takes_value(true)
.min_values(1)
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::DirPath),
)
}

View file

@ -16,7 +16,7 @@ path = "src/mkfifo.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[[bin]]

View file

@ -102,6 +102,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FIFO)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -17,7 +17,7 @@ path = "src/mknod.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "^0.2.125"
libc = "^0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] }
[[bin]]

View file

@ -162,7 +162,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.value_name("NAME")
.help("name of the new file")
.required(true)
.index(1),
.index(1)
.value_hint(clap::ValueHint::AnyPath),
)
.arg(
Arg::new("type")

View file

@ -41,7 +41,12 @@ enum MkTempError {
PersistError(PathBuf),
MustEndInX(String),
TooFewXs(String),
ContainsDirSeparator(String),
/// The template prefix contains a path separator (e.g. `"a/bXXX"`).
PrefixContainsDirSeparator(String),
/// The template suffix contains a path separator (e.g. `"XXXa/b"`).
SuffixContainsDirSeparator(String),
InvalidTemplate(String),
}
@ -56,7 +61,14 @@ impl Display for MkTempError {
PersistError(p) => write!(f, "could not persist file {}", p.quote()),
MustEndInX(s) => write!(f, "with --suffix, template {} must end in X", s.quote()),
TooFewXs(s) => write!(f, "too few X's in template {}", s.quote()),
ContainsDirSeparator(s) => {
PrefixContainsDirSeparator(s) => {
write!(
f,
"invalid template, {}, contains directory separator",
s.quote()
)
}
SuffixContainsDirSeparator(s) => {
write!(
f,
"invalid suffix {}, contains directory separator",
@ -190,7 +202,8 @@ pub fn uu_app<'a>() -> Command<'a> {
be an absolute name; unlike with -t, TEMPLATE may contain \
slashes, but mktemp creates only the final component",
)
.value_name("DIR"),
.value_name("DIR")
.value_hint(clap::ValueHint::DirPath),
)
.arg(Arg::new(OPT_T).short('t').help(
"Generate a template (using the supplied prefix and TMPDIR (TMP on windows) if set) \
@ -252,8 +265,12 @@ fn parse_template<'a>(
}
};
if prefix.chars().any(is_separator) {
return Err(MkTempError::PrefixContainsDirSeparator(temp.into()));
}
if suf.chars().any(is_separator) {
return Err(MkTempError::ContainsDirSeparator(suf.into()));
return Err(MkTempError::SuffixContainsDirSeparator(suf.into()));
}
Ok((prefix, rand, suf))
@ -352,11 +369,7 @@ mod tests {
#[test]
fn test_parse_template_errors() {
// TODO This should be an error as well, but we are not
// catching it just yet. A future commit will correct this.
//
// assert!(parse_template("a/bXXX", None).is_err());
//
assert!(parse_template("a/bXXX", None).is_err());
assert!(parse_template("XXXa/b", None).is_err());
assert!(parse_template("XX", None).is_err());
assert!(parse_template("XXXabc", Some("def")).is_err());

View file

@ -183,7 +183,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::FILES)
.required(false)
.multiple_occurrences(true)
.help("Path to the files to be read"),
.help("Path to the files to be read")
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -156,14 +156,15 @@ pub fn uu_app<'a>() -> Command<'a> {
.help("move all SOURCE arguments into DIRECTORY")
.takes_value(true)
.value_name("DIRECTORY")
.value_hint(clap::ValueHint::DirPath)
.conflicts_with(OPT_NO_TARGET_DIRECTORY)
.allow_invalid_utf8(true)
)
.arg(
Arg::new(OPT_NO_TARGET_DIRECTORY)
.short('T')
.long(OPT_NO_TARGET_DIRECTORY).
help("treat DEST as a normal file")
.long(OPT_NO_TARGET_DIRECTORY)
.help("treat DEST as a normal file")
)
.arg(
Arg::new(OPT_UPDATE)
@ -183,6 +184,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.min_values(2)
.required(true)
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::AnyPath)
)
}

View file

@ -16,7 +16,7 @@ path = "src/nice.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
nix = { version = "0.24.1", default-features = false }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }

View file

@ -117,5 +117,9 @@ pub fn uu_app<'a>() -> Command<'a> {
.takes_value(true)
.allow_hyphen_values(true),
)
.arg(Arg::new(options::COMMAND).multiple_occurrences(true))
.arg(
Arg::new(options::COMMAND)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::CommandName),
)
}

View file

@ -154,7 +154,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::BODY_NUMBERING)

View file

@ -16,7 +16,7 @@ path = "src/nohup.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
atty = "0.2"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }

View file

@ -126,7 +126,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::CMD)
.hide(true)
.required(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::CommandName),
)
.trailing_var_arg(true)
.infer_long_args(true)

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/nproc.rs"
[dependencies]
libc = "0.2.125"
libc = "0.2.126"
num_cpus = "1.10"
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }

View file

@ -244,7 +244,7 @@ fn format_string(
p => format!(
"{:<padding$}",
number_with_suffix,
padding = p.abs() as usize
padding = p.unsigned_abs()
),
})
}

View file

@ -29,6 +29,7 @@ mod prn_float;
mod prn_int;
use std::cmp;
use std::fmt::Write;
use crate::byteorder_io::*;
use crate::formatteriteminfo::*;
@ -512,7 +513,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILENAME)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}
@ -599,11 +601,13 @@ fn print_bytes(prefix: &str, input_decoder: &MemoryDecoder, output_info: &Output
let mut b = 0;
while b < input_decoder.length() {
output_text.push_str(&format!(
write!(
output_text,
"{:>width$}",
"",
width = f.spacing[b % output_info.byte_size_block]
));
)
.unwrap();
match f.formatter_item_info.formatter {
FormatWriter::IntWriter(func) => {
@ -626,12 +630,14 @@ fn print_bytes(prefix: &str, input_decoder: &MemoryDecoder, output_info: &Output
let missing_spacing = output_info
.print_width_line
.saturating_sub(output_text.chars().count());
output_text.push_str(&format!(
write!(
output_text,
"{:>width$} {}",
"",
format_ascii_dump(input_decoder.get_buffer(0)),
width = missing_spacing
));
)
.unwrap();
}
if first {
@ -673,8 +679,10 @@ fn open_input_peek_reader(
fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String {
// NOTE:
// GNU's od echos affected flag, -N or --read-bytes (-j or --skip-bytes, etc.), depending user's selection
// GNU's od does distinguish between "invalid (suffix in) argument"
match error {
ParseSizeError::InvalidSuffix(_) => {
format!("invalid suffix in --{} argument {}", option, s.quote())
}
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument {}", option, s.quote()),
ParseSizeError::SizeTooBig(_) => format!("--{} argument {} too large", option, s.quote()),
}

View file

@ -244,7 +244,7 @@ fn is_format_size_decimal(
return false;
}
match ch {
Some(d) if d.is_digit(10) => {
Some(d) if d.is_ascii_digit() => {
decimal_size.push(d);
true
}

View file

@ -10,7 +10,7 @@ pub trait CommandLineOpts {
}
/// Implementation for `getopts`
impl<'a> CommandLineOpts for ArgMatches {
impl CommandLineOpts for ArgMatches {
fn inputs(&self) -> Vec<&str> {
self.values_of(options::FILENAME)
.map(|values| values.collect())

View file

@ -71,7 +71,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::FILE)
.value_name("FILE")
.multiple_occurrences(true)
.default_value("-"),
.default_value("-")
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -16,7 +16,7 @@ path = "src/pathchk.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[[bin]]

View file

@ -108,7 +108,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::PATH)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -179,7 +179,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::USER)
.takes_value(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::Username),
)
.arg(
// Redefine the help argument to not include the short flag

View file

@ -372,6 +372,7 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::FILES)
.multiple_occurrences(true)
.multiple_values(true)
.value_hint(clap::ValueHint::FilePath)
)
}

View file

@ -13,7 +13,7 @@ use std::cmp;
use std::collections::{BTreeSet, HashMap, HashSet};
use std::default::Default;
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::fmt::{Display, Formatter, Write as FmtWrite};
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::num::ParseIntError;
@ -572,7 +572,7 @@ fn format_tex_line(
reference: &str,
) -> String {
let mut output = String::new();
output.push_str(&format!("\\{} ", config.macro_name));
write!(output, "\\{} ", config.macro_name).unwrap();
let all_before = if config.input_ref {
let before = &line[0..word_ref.position];
let before_start_trim_offset =
@ -587,18 +587,18 @@ fn format_tex_line(
let after_chars_trim_idx = (word_ref.position_end, chars_line.len());
let all_after = &chars_line[after_chars_trim_idx.0..after_chars_trim_idx.1];
let (tail, before, after, head) = get_output_chunks(all_before, keyword, all_after, config);
output.push_str(&format!(
"{5}{0}{6}{5}{1}{6}{5}{2}{6}{5}{3}{6}{5}{4}{6}",
write!(
output,
"{{{0}}}{{{1}}}{{{2}}}{{{3}}}{{{4}}}",
format_tex_field(&tail),
format_tex_field(&before),
format_tex_field(keyword),
format_tex_field(&after),
format_tex_field(&head),
"{",
"}"
));
)
.unwrap();
if config.auto_ref || config.input_ref {
output.push_str(&format!("{}{}{}", "{", format_tex_field(reference), "}"));
write!(output, "{{{}}}", format_tex_field(reference)).unwrap();
}
output
}
@ -615,7 +615,7 @@ fn format_roff_line(
reference: &str,
) -> String {
let mut output = String::new();
output.push_str(&format!(".{}", config.macro_name));
write!(output, ".{}", config.macro_name).unwrap();
let all_before = if config.input_ref {
let before = &line[0..word_ref.position];
let before_start_trim_offset =
@ -630,16 +630,18 @@ fn format_roff_line(
let after_chars_trim_idx = (word_ref.position_end, chars_line.len());
let all_after = &chars_line[after_chars_trim_idx.0..after_chars_trim_idx.1];
let (tail, before, after, head) = get_output_chunks(all_before, keyword, all_after, config);
output.push_str(&format!(
write!(
output,
" \"{}\" \"{}\" \"{}{}\" \"{}\"",
format_roff_field(&tail),
format_roff_field(&before),
format_roff_field(keyword),
format_roff_field(&after),
format_roff_field(&head)
));
)
.unwrap();
if config.auto_ref || config.input_ref {
output.push_str(&format!(" \"{}\"", format_roff_field(reference)));
write!(output, " \"{}\"", format_roff_field(reference)).unwrap();
}
output
}
@ -754,7 +756,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::AUTO_REFERENCE)
@ -826,7 +829,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::BREAK_FILE)
.help("word break characters in this FILE")
.value_name("FILE")
.takes_value(true),
.takes_value(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::IGNORE_CASE)
@ -849,7 +853,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::IGNORE_FILE)
.help("read ignore word list from FILE")
.value_name("FILE")
.takes_value(true),
.takes_value(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::ONLY_FILE)
@ -857,7 +862,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::ONLY_FILE)
.help("read only word list from this FILE")
.value_name("FILE")
.takes_value(true),
.takes_value(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::REFERENCES)

View file

@ -161,7 +161,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true),
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -130,7 +130,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.takes_value(true)
.required(true)
.min_values(1),
.min_values(1)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -87,6 +87,15 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(Arg::new(options::DIR).short('d').takes_value(true).help(
"If any of FROM and TO is not subpath of DIR, output absolute path instead of relative",
))
.arg(Arg::new(options::TO).required(true).takes_value(true))
.arg(Arg::new(options::FROM).takes_value(true))
.arg(
Arg::new(options::TO)
.required(true)
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath),
)
.arg(
Arg::new(options::FROM)
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -227,6 +227,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.takes_value(true)
.min_values(1)
.value_hint(clap::ValueHint::AnyPath)
)
}

View file

@ -17,7 +17,7 @@ path = "src/rmdir.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
libc = "0.2.125"
libc = "0.2.126"
[[bin]]
name = "rmdir"

View file

@ -197,6 +197,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.takes_value(true)
.min_values(1)
.required(true)
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::DirPath),
)
}

View file

@ -156,7 +156,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new("ARG")
.multiple_occurrences(true)
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::CommandName),
)
// Once "ARG" is parsed, everything after that belongs to it.
//

View file

@ -374,7 +374,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -158,14 +158,16 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::OUTPUT)
.takes_value(true)
.value_name("FILE")
.help("write result to FILE instead of standard output"),
.help("write result to FILE instead of standard output")
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::RANDOM_SOURCE)
.long(options::RANDOM_SOURCE)
.takes_value(true)
.value_name("FILE")
.help("get random bytes from FILE"),
.help("get random bytes from FILE")
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::REPEAT)
@ -179,7 +181,11 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::ZERO_TERMINATED)
.help("line delimiter is NUL, not newline"),
)
.arg(Arg::new(options::FILE).takes_value(true))
.arg(
Arg::new(options::FILE)
.takes_value(true)
.value_hint(clap::ValueHint::FilePath),
)
}
fn read_input_file(filename: &str) -> UResult<Vec<u8>> {

View file

@ -348,9 +348,9 @@ impl GlobalSettings {
];
let mut size_string = input.trim().to_string();
if size_string.ends_with(|c: char| ALLOW_LIST.contains(&c) || c.is_digit(10)) {
if size_string.ends_with(|c: char| ALLOW_LIST.contains(&c) || c.is_ascii_digit()) {
// b 1, K 1024 (default)
if size_string.ends_with(|c: char| c.is_digit(10)) {
if size_string.ends_with(|c: char| c.is_ascii_digit()) {
size_string.push('K');
} else if size_string.ends_with('b') {
size_string.pop();
@ -362,8 +362,10 @@ impl GlobalSettings {
size
))
})
} else if size_string.starts_with(|c: char| c.is_ascii_digit()) {
Err(ParseSizeError::InvalidSuffix("invalid suffix".to_string()))
} else {
Err(ParseSizeError::ParseFailure("invalid suffix".to_string()))
Err(ParseSizeError::ParseFailure("parse failure".to_string()))
}
}
@ -1397,7 +1399,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::OUTPUT)
.help("write output to FILENAME instead of stdout")
.takes_value(true)
.value_name("FILENAME"),
.value_name("FILENAME")
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::REVERSE)
@ -1461,13 +1464,15 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::TMP_DIR)
.help("use DIR for temporaries, not $TMPDIR or /tmp")
.takes_value(true)
.value_name("DIR"),
.value_name("DIR")
.value_hint(clap::ValueHint::DirPath),
)
.arg(
Arg::new(options::COMPRESS_PROG)
.long(options::COMPRESS_PROG)
.help("compress temporary files with PROG, decompress with PROG -d; PROG has to take input from stdin and output to stdout")
.value_name("PROG"),
.value_name("PROG")
.value_hint(clap::ValueHint::CommandName),
)
.arg(
Arg::new(options::BATCH_SIZE)
@ -1482,7 +1487,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.takes_value(true)
.value_name("NUL_FILES")
.multiple_occurrences(true)
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::DEBUG)
@ -1493,7 +1499,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::FILES)
.multiple_occurrences(true)
.takes_value(true)
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::FilePath),
)
}
@ -1828,8 +1835,10 @@ fn open(path: impl AsRef<OsStr>) -> UResult<Box<dyn Read + Send>> {
fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String {
// NOTE:
// GNU's sort echos affected flag, -S or --buffer-size, depending user's selection
// GNU's sort does distinguish between "invalid (suffix in) argument"
match error {
ParseSizeError::InvalidSuffix(_) => {
format!("invalid suffix in --{} argument {}", option, s.quote())
}
ParseSizeError::ParseFailure(_) => format!("invalid --{} argument {}", option, s.quote()),
ParseSizeError::SizeTooBig(_) => format!("--{} argument {} too large", option, s.quote()),
}

View file

@ -111,8 +111,10 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(OPT_FILTER)
.long(OPT_FILTER)
.takes_value(true)
.value_name("COMMAND")
.value_hint(clap::ValueHint::CommandName)
.help(
"write to shell COMMAND file name is $FILE (Currently not implemented for Windows)",
"write to shell COMMAND; file name is $FILE (Currently not implemented for Windows)",
),
)
.arg(
@ -162,7 +164,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(ARG_INPUT)
.takes_value(true)
.default_value("-")
.index(1),
.index(1)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(ARG_PREFIX)

View file

@ -19,7 +19,9 @@ use uucore::{entries, format_usage};
use clap::{crate_version, Arg, ArgMatches, Command};
use std::borrow::Cow;
use std::convert::AsRef;
use std::ffi::{OsStr, OsString};
use std::os::unix::fs::{FileTypeExt, MetadataExt};
use std::os::unix::prelude::OsStrExt;
use std::path::Path;
use std::{cmp, fs, iter};
@ -195,8 +197,8 @@ impl ScanUtil for str {
pub fn group_num(s: &str) -> Cow<str> {
let is_negative = s.starts_with('-');
assert!(is_negative || s.chars().take(1).all(|c| c.is_digit(10)));
assert!(s.chars().skip(1).all(|c| c.is_digit(10)));
assert!(is_negative || s.chars().take(1).all(|c| c.is_ascii_digit()));
assert!(s.chars().skip(1).all(|c| c.is_ascii_digit()));
if s.len() < 4 {
return s.into();
}
@ -221,7 +223,7 @@ pub struct Stater {
follow: bool,
show_fs: bool,
from_user: bool,
files: Vec<String>,
files: Vec<OsString>,
mount_list: Option<Vec<String>>,
default_tokens: Vec<Token>,
default_dev_tokens: Vec<Token>,
@ -471,24 +473,10 @@ impl Stater {
}
fn new(matches: &ArgMatches) -> UResult<Self> {
let mut files: Vec<String> = matches
.values_of(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect())
let files = matches
.values_of_os(ARG_FILES)
.map(|v| v.map(OsString::from).collect())
.unwrap_or_default();
#[cfg(unix)]
if files.contains(&String::from("-")) {
let redirected_path = Path::new("/dev/stdin")
.canonicalize()
.expect("unable to canonicalize /dev/stdin")
.into_os_string()
.into_string()
.unwrap();
for file in &mut files {
if file == "-" {
*file = redirected_path.clone();
}
}
}
let format_str = if matches.is_present(options::PRINTF) {
matches
.value_of(options::PRINTF)
@ -550,19 +538,37 @@ impl Stater {
}
fn exec(&self) -> i32 {
let mut stdin_is_fifo = false;
if cfg!(unix) {
if let Ok(md) = fs::metadata("/dev/stdin") {
stdin_is_fifo = md.file_type().is_fifo();
}
}
let mut ret = 0;
for f in &self.files {
ret |= self.do_stat(f.as_str());
ret |= self.do_stat(f, stdin_is_fifo);
}
ret
}
fn do_stat(&self, file: &str) -> i32 {
if !self.show_fs {
let result = if self.follow {
fs::metadata(file)
fn do_stat(&self, file: &OsStr, stdin_is_fifo: bool) -> i32 {
let display_name = file.to_string_lossy();
let file: OsString = if cfg!(unix) && display_name.eq("-") {
if let Ok(p) = Path::new("/dev/stdin").canonicalize() {
p.into_os_string()
} else {
fs::symlink_metadata(file)
OsString::from("/dev/stdin")
}
} else {
OsString::from(file)
};
if !self.show_fs {
let result = if self.follow || stdin_is_fifo && display_name.eq("-") {
fs::metadata(&file)
} else {
fs::symlink_metadata(&file)
};
match result {
Ok(meta) => {
@ -658,28 +664,32 @@ impl Stater {
// mount point
'm' => {
arg = self.find_mount_point(file).unwrap();
arg = self.find_mount_point(&file).unwrap();
output_type = OutputType::Str;
}
// file name
'n' => {
arg = file.to_owned();
arg = display_name.to_string();
output_type = OutputType::Str;
}
// quoted file name with dereference if symbolic link
'N' => {
if file_type.is_symlink() {
let dst = match fs::read_link(file) {
let dst = match fs::read_link(&file) {
Ok(path) => path,
Err(e) => {
println!("{}", e);
return 1;
}
};
arg = format!("{} -> {}", file.quote(), dst.quote());
arg = format!(
"{} -> {}",
display_name.quote(),
dst.quote()
);
} else {
arg = file.to_string();
arg = display_name.to_string();
}
output_type = OutputType::Str;
}
@ -771,12 +781,16 @@ impl Stater {
}
}
Err(e) => {
show_error!("cannot stat {}: {}", file.quote(), e);
show_error!("cannot stat {}: {}", display_name.quote(), e);
return 1;
}
}
} else {
match statfs(file) {
#[cfg(unix)]
let p = file.as_bytes();
#[cfg(not(unix))]
let p = file.into_string().unwrap();
match statfs(p) {
Ok(meta) => {
let tokens = &self.default_tokens;
@ -829,7 +843,7 @@ impl Stater {
}
// file name
'n' => {
arg = file.to_owned();
arg = display_name.to_string();
output_type = OutputType::Str;
}
// block size (for faster transfers)
@ -866,7 +880,7 @@ impl Stater {
Err(e) => {
show_error!(
"cannot read file system information for {}: {}",
file.quote(),
display_name.quote(),
e
);
return 1;
@ -1028,6 +1042,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true)
.min_values(1),
.allow_invalid_utf8(true)
.min_values(1)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -62,7 +62,7 @@ struct ProgramOptions {
stderr: BufferType,
}
impl<'a> TryFrom<&ArgMatches> for ProgramOptions {
impl TryFrom<&ArgMatches> for ProgramOptions {
type Error = ProgramOptionsError;
fn try_from(matches: &ArgMatches) -> Result<Self, Self::Error> {
@ -232,6 +232,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.takes_value(true)
.hide(true)
.required(true),
.required(true)
.value_hint(clap::ValueHint::CommandName),
)
}

View file

@ -150,7 +150,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.multiple_occurrences(true)
.hide(true),
.hide(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::BSD_COMPATIBLE)

View file

@ -16,7 +16,7 @@ path = "src/sync.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] }
winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] }

View file

@ -217,7 +217,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true),
.takes_value(true)
.value_hint(clap::ValueHint::AnyPath),
)
}

View file

@ -91,7 +91,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -16,7 +16,7 @@ path = "src/tail.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer", "lines"] }
[target.'cfg(windows)'.dependencies]

View file

@ -19,7 +19,7 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
let mut has_num = false;
let mut last_char = 0 as char;
for (n, c) in &mut chars {
if c.is_digit(10) {
if c.is_ascii_digit() {
has_num = true;
num_end = n;
} else {

View file

@ -351,7 +351,8 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::ARG_FILES)
.multiple_occurrences(true)
.takes_value(true)
.min_values(1),
.min_values(1)
.value_hint(clap::ValueHint::FilePath),
)
}

View file

@ -16,7 +16,7 @@ path = "src/tee.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
retain_mut = "=0.1.7" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] }

View file

@ -74,7 +74,11 @@ pub fn uu_app<'a>() -> Command<'a> {
.short('i')
.help("ignore interrupt signals (ignored on non-Unix platforms)"),
)
.arg(Arg::new(options::FILE).multiple_occurrences(true))
.arg(
Arg::new(options::FILE)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::FilePath),
)
}
#[cfg(unix)]

View file

@ -16,7 +16,7 @@ path = "src/test.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[target.'cfg(target_os = "redox")'.dependencies]

View file

@ -16,7 +16,7 @@ path = "src/timeout.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.125"
libc = "0.2.126"
nix = { version = "0.24.1", default-features = false, features = ["signal"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] }

View file

@ -170,6 +170,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.index(2)
.required(true)
.multiple_occurrences(true)
.value_hint(clap::ValueHint::CommandName)
)
.trailing_var_arg(true)
.infer_long_args(true)

View file

@ -219,7 +219,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.long(options::sources::REFERENCE)
.help("use this file's times instead of the current time")
.value_name("FILE")
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::AnyPath),
)
.arg(
Arg::new(options::TIME)
@ -238,7 +239,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.takes_value(true)
.min_values(1)
.allow_invalid_utf8(true),
.allow_invalid_utf8(true)
.value_hint(clap::ValueHint::AnyPath),
)
.group(ArgGroup::new(options::SOURCES).args(&[
options::sources::CURRENT,

View file

@ -143,7 +143,6 @@ pub fn uu_app<'a>() -> Command<'a> {
.about(ABOUT)
.override_usage(format_usage(USAGE))
.infer_long_args(true)
.infer_long_args(true)
.arg(
Arg::new(options::COMPLEMENT)
.visible_short_alias('C')

View file

@ -162,6 +162,7 @@ pub fn uu_app<'a>() -> Command<'a> {
.required_unless_present(options::SIZE)
.help("base the size of each file on the size of RFILE")
.value_name("RFILE")
.value_hint(clap::ValueHint::FilePath)
)
.arg(
Arg::new(options::SIZE)
@ -176,7 +177,8 @@ pub fn uu_app<'a>() -> Command<'a> {
.multiple_occurrences(true)
.takes_value(true)
.required(true)
.min_values(1))
.min_values(1)
.value_hint(clap::ValueHint::FilePath))
}
/// Truncate the named file to the specified size.

View file

@ -50,11 +50,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let mut line = String::new();
match reader.read_line(&mut line) {
Ok(_) => {
let tokens: Vec<String> = line
.trim_end()
.split_whitespace()
.map(|s| s.to_owned())
.collect();
let tokens: Vec<String> = line.split_whitespace().map(|s| s.to_owned()).collect();
if tokens.is_empty() {
break;
}
@ -99,7 +95,12 @@ pub fn uu_app<'a>() -> Command<'a> {
.override_usage(format_usage(USAGE))
.about(SUMMARY)
.infer_long_args(true)
.arg(Arg::new(options::FILE).default_value("-").hide(true))
.arg(
Arg::new(options::FILE)
.default_value("-")
.hide(true)
.value_hint(clap::ValueHint::FilePath),
)
}
// We use String as a representation of node here

Some files were not shown because too many files have changed in this diff Show more