mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge branch 'master' of github.com:uutils/coreutils into hbina-tr-reimplement-expansion
Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
-21
@@ -1,21 +0,0 @@
|
||||
env:
|
||||
# Temporary workaround for error `error: sysinfo not supported on
|
||||
# this platform` seen on FreeBSD platforms, affecting Rustup
|
||||
#
|
||||
# References: https://github.com/rust-lang/rustup/issues/2774
|
||||
RUSTUP_IO_THREADS: 1
|
||||
|
||||
task:
|
||||
name: stable x86_64-unknown-freebsd-12
|
||||
freebsd_instance:
|
||||
image: freebsd-12-2-release-amd64
|
||||
setup_script:
|
||||
- pkg install -y curl gmake
|
||||
- curl https://sh.rustup.rs -sSf --output rustup.sh
|
||||
- sh rustup.sh -y --profile=minimal
|
||||
build_script:
|
||||
- . $HOME/.cargo/env
|
||||
- cargo build
|
||||
test_script:
|
||||
- . $HOME/.cargo/env
|
||||
- cargo test -p uucore -p coreutils
|
||||
@@ -14,7 +14,6 @@ env:
|
||||
PROJECT_DESC: "Core universal (cross-platform) utilities"
|
||||
PROJECT_AUTH: "uutils"
|
||||
RUST_MIN_SRV: "1.47.0" ## MSRV v1.47.0
|
||||
RUST_COV_SRV: "2021-05-06" ## (~v1.52.0) supported rust version for code coverage; (date required/used by 'coverage') ## !maint: refactor when code coverage support is included in the stable channel
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
@@ -102,11 +101,17 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { os: ubuntu-latest , features: feat_os_unix }
|
||||
- { os: ubuntu-latest }
|
||||
- { os: macos-latest , features: feat_os_macos }
|
||||
- { os: windows-latest , features: feat_os_windows }
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install/setup prerequisites
|
||||
shell: bash
|
||||
run: |
|
||||
case '${{ matrix.job.os }}' in
|
||||
macos-latest) brew install coreutils ;; # needed for show-utils.sh
|
||||
esac
|
||||
- name: Initialize workflow variables
|
||||
id: vars
|
||||
shell: bash
|
||||
@@ -115,9 +120,14 @@ jobs:
|
||||
outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; }
|
||||
# target-specific options
|
||||
# * CARGO_FEATURES_OPTION
|
||||
CARGO_FEATURES_OPTION='' ;
|
||||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
|
||||
CARGO_FEATURES_OPTION='--all-features' ;
|
||||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features ${{ matrix.job.features }}' ; fi
|
||||
outputs CARGO_FEATURES_OPTION
|
||||
# * determine sub-crate utility list
|
||||
UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})"
|
||||
echo UTILITY_LIST=${UTILITY_LIST}
|
||||
CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo "-puu_${u}"; done;)"
|
||||
outputs CARGO_UTILITY_LIST_OPTIONS
|
||||
- name: Install `rust` toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
@@ -130,7 +140,7 @@ jobs:
|
||||
run: |
|
||||
## `clippy` lint testing
|
||||
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
||||
S=$(cargo +nightly clippy --all-targets ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+${PWD//\//\\/}\/(.*):([0-9]+):([0-9]+).*$/::error file=\2,line=\3,col=\4::ERROR: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; exit 1 ; }
|
||||
S=$(cargo +nightly clippy --all-targets ${{ steps.vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+${PWD//\//\\/}\/(.*):([0-9]+):([0-9]+).*$/::error file=\2,line=\3,col=\4::ERROR: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; exit 1 ; }
|
||||
|
||||
code_spellcheck:
|
||||
name: Style/spelling
|
||||
@@ -521,6 +531,52 @@ jobs:
|
||||
n_fails=$(echo "$output" | grep "^FAIL:\s" | wc --lines)
|
||||
if [ $n_fails -gt 0 ] ; then echo "::warning ::${n_fails}+ test failures" ; fi
|
||||
|
||||
test_freebsd:
|
||||
runs-on: macos-latest
|
||||
name: Tests/FreeBSD test suite
|
||||
env:
|
||||
mem: 2048
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Prepare, build and test
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v0.1.5
|
||||
with:
|
||||
usesh: true
|
||||
prepare: pkg install -y curl gmake sudo
|
||||
run: |
|
||||
# Need to be run in the same block. Otherwise, we are back on the mac host.
|
||||
set -e
|
||||
pw adduser -n cuuser -d /root/ -g wheel -c "Coreutils user to build" -w random
|
||||
chown -R cuuser:wheel /root/ /Users/runner/work/coreutils/
|
||||
whoami
|
||||
|
||||
# Needs to be done in a sudo as we are changing users
|
||||
sudo -i -u cuuser sh << EOF
|
||||
set -e
|
||||
whoami
|
||||
curl https://sh.rustup.rs -sSf --output rustup.sh
|
||||
sh rustup.sh -y --profile=minimal
|
||||
## Info
|
||||
# environment
|
||||
echo "## environment"
|
||||
echo "CI='${CI}'"
|
||||
# tooling info display
|
||||
echo "## tooling"
|
||||
. $HOME/.cargo/env
|
||||
cargo -V
|
||||
rustc -V
|
||||
env
|
||||
|
||||
# where the files are resynced
|
||||
cd /Users/runner/work/coreutils/coreutils/
|
||||
cargo build
|
||||
cargo test --features feat_os_unix -p uucore -p coreutils
|
||||
# Clean to avoid to rsync back the files
|
||||
cargo clean
|
||||
EOF
|
||||
|
||||
|
||||
coverage:
|
||||
name: Code Coverage
|
||||
runs-on: ${{ matrix.job.os }}
|
||||
@@ -550,7 +606,7 @@ jobs:
|
||||
## VARs setup
|
||||
outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; }
|
||||
# toolchain
|
||||
TOOLCHAIN="nightly-${{ env.RUST_COV_SRV }}" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
|
||||
TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
|
||||
# * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
|
||||
case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
|
||||
# * use requested TOOLCHAIN if specified
|
||||
@@ -652,3 +708,35 @@ jobs:
|
||||
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: false
|
||||
|
||||
unused_deps:
|
||||
name: Unused deps
|
||||
runs-on: ${{ matrix.job.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { os: ubuntu-latest , features: feat_os_unix }
|
||||
- { os: macos-latest , features: feat_os_macos }
|
||||
- { os: windows-latest , features: feat_os_windows }
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install `rust` toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
default: true
|
||||
profile: minimal
|
||||
- name: Install `cargo-udeps`
|
||||
uses: actions-rs/install@v0.1
|
||||
with:
|
||||
crate: cargo-udeps
|
||||
version: latest
|
||||
use-tool-cache: true
|
||||
env:
|
||||
RUSTUP_TOOLCHAIN: stable
|
||||
- name: Confirms there isn't any unused deps
|
||||
shell: bash
|
||||
run: |
|
||||
cargo +nightly udeps --all-targets &> udeps.log || cat udeps.log
|
||||
grep "seem to have been used" udeps.log
|
||||
|
||||
@@ -11,7 +11,7 @@ repos:
|
||||
- id: rust-clippy
|
||||
name: Rust clippy
|
||||
description: Run cargo clippy on files included in the commit.
|
||||
entry: cargo +nightly clippy --all-targets --all-features --
|
||||
entry: cargo +nightly clippy --workspace --all-targets --all-features --
|
||||
pass_filenames: false
|
||||
types: [file, rust]
|
||||
language: system
|
||||
|
||||
+11
@@ -1,3 +1,4 @@
|
||||
AFAICT
|
||||
arity
|
||||
autogenerate
|
||||
autogenerated
|
||||
@@ -8,6 +9,8 @@ bytewise
|
||||
canonicalization
|
||||
canonicalize
|
||||
canonicalizing
|
||||
codepoint
|
||||
codepoints
|
||||
colorizable
|
||||
colorize
|
||||
coprime
|
||||
@@ -35,10 +38,14 @@ falsey
|
||||
fileio
|
||||
flamegraph
|
||||
fullblock
|
||||
getfacl
|
||||
gibi
|
||||
gibibytes
|
||||
glob
|
||||
globbing
|
||||
hardcode
|
||||
hardcoded
|
||||
hardcoding
|
||||
hardfloat
|
||||
hardlink
|
||||
hardlinks
|
||||
@@ -49,7 +56,9 @@ iflag
|
||||
iflags
|
||||
kibi
|
||||
kibibytes
|
||||
libacl
|
||||
lcase
|
||||
lossily
|
||||
mebi
|
||||
mebibytes
|
||||
mergeable
|
||||
@@ -90,6 +99,7 @@ seedable
|
||||
semver
|
||||
semiprime
|
||||
semiprimes
|
||||
setfacl
|
||||
shortcode
|
||||
shortcodes
|
||||
siginfo
|
||||
@@ -107,6 +117,7 @@ toolchain
|
||||
truthy
|
||||
ucase
|
||||
unbuffered
|
||||
udeps
|
||||
unescape
|
||||
unintuitive
|
||||
unprefixed
|
||||
|
||||
@@ -8,6 +8,7 @@ csh
|
||||
globstar
|
||||
inotify
|
||||
localtime
|
||||
mksh
|
||||
mountinfo
|
||||
mountpoint
|
||||
mtab
|
||||
@@ -91,6 +92,7 @@ rerast
|
||||
rollup
|
||||
sed
|
||||
selinuxenabled
|
||||
sestatus
|
||||
wslpath
|
||||
xargs
|
||||
|
||||
|
||||
+15
-1
@@ -9,12 +9,14 @@ aho-corasick
|
||||
backtrace
|
||||
blake2b_simd
|
||||
bstr
|
||||
bytecount
|
||||
byteorder
|
||||
chacha
|
||||
chrono
|
||||
conv
|
||||
corasick
|
||||
crossterm
|
||||
exacl
|
||||
filetime
|
||||
formatteriteminfo
|
||||
fsext
|
||||
@@ -66,6 +68,7 @@ structs
|
||||
substr
|
||||
splitn
|
||||
trunc
|
||||
uninit
|
||||
|
||||
# * uutils
|
||||
basenc
|
||||
@@ -106,12 +109,18 @@ whoami
|
||||
|
||||
# * vars/errno
|
||||
errno
|
||||
EACCES
|
||||
EBADF
|
||||
EBUSY
|
||||
EEXIST
|
||||
EINVAL
|
||||
ENODATA
|
||||
ENOENT
|
||||
ENOSYS
|
||||
EPERM
|
||||
ENOTEMPTY
|
||||
EOPNOTSUPP
|
||||
EPERM
|
||||
EROFS
|
||||
|
||||
# * vars/fcntl
|
||||
F_GETFL
|
||||
@@ -162,6 +171,7 @@ blocksize
|
||||
canonname
|
||||
chroot
|
||||
dlsym
|
||||
execvp
|
||||
fdatasync
|
||||
freeaddrinfo
|
||||
getaddrinfo
|
||||
@@ -268,6 +278,7 @@ ULONG
|
||||
ULONGLONG
|
||||
UNLEN
|
||||
WCHAR
|
||||
WSADATA
|
||||
errhandlingapi
|
||||
fileapi
|
||||
handleapi
|
||||
@@ -313,3 +324,6 @@ uucore_procs
|
||||
uumain
|
||||
uutil
|
||||
uutils
|
||||
|
||||
# * function names
|
||||
getcwd
|
||||
|
||||
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
{
|
||||
}
|
||||
Generated
+382
-202
File diff suppressed because it is too large
Load Diff
+119
-108
@@ -5,7 +5,7 @@
|
||||
|
||||
[package]
|
||||
name = "coreutils"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
authors = ["uutils developers"]
|
||||
license = "MIT"
|
||||
description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust"
|
||||
@@ -95,8 +95,10 @@ feat_common_core = [
|
||||
"true",
|
||||
"truncate",
|
||||
"tsort",
|
||||
"touch",
|
||||
"unexpand",
|
||||
"uniq",
|
||||
"unlink",
|
||||
"wc",
|
||||
"yes",
|
||||
]
|
||||
@@ -146,7 +148,12 @@ feat_os_unix_musl = [
|
||||
# NOTE:
|
||||
# The selinux(-sys) crate requires `libselinux` headers and shared library to be accessible in the C toolchain at compile time.
|
||||
# Running a uutils compiled with `feat_selinux` requires an SELinux enabled Kernel at run time.
|
||||
feat_selinux = ["id/selinux", "selinux", "feat_require_selinux"]
|
||||
feat_selinux = ["cp/selinux", "id/selinux", "ls/selinux", "selinux", "feat_require_selinux"]
|
||||
# "feat_acl" == set of utilities providing support for acl (access control lists) if enabled with `--features feat_acl`.
|
||||
# NOTE:
|
||||
# On linux, the posix-acl/acl-sys crate requires `libacl` headers and shared library to be accessible in the C toolchain at compile time.
|
||||
# On FreeBSD and macOS this is not required.
|
||||
feat_acl = ["cp/feat_acl"]
|
||||
## feature sets with requirements (restricting cross-platform availability)
|
||||
#
|
||||
# ** NOTE: these `feat_require_...` sets should be minimized as much as possible to encourage cross-platform availability of utilities
|
||||
@@ -176,7 +183,6 @@ feat_require_unix = [
|
||||
"timeout",
|
||||
"tty",
|
||||
"uname",
|
||||
"unlink",
|
||||
]
|
||||
# "feat_require_unix_utmpx" == set of utilities requiring unix utmp/utmpx support
|
||||
# * ref: <https://wiki.musl-libc.org/faq.html#Q:-Why-is-the-utmp/wtmp-functionality-only-implemented-as-stubs?>
|
||||
@@ -189,6 +195,7 @@ feat_require_unix_utmpx = [
|
||||
# "feat_require_selinux" == set of utilities depending on SELinux.
|
||||
feat_require_selinux = [
|
||||
"chcon",
|
||||
"runcon",
|
||||
]
|
||||
## (alternate/newer/smaller platforms) feature sets
|
||||
# "feat_os_unix_fuchsia" == set of utilities which can be built/run on the "Fuchsia" OS (refs: <https://fuchsia.dev>; <https://en.wikipedia.org/wiki/Google_Fuchsia>)
|
||||
@@ -239,110 +246,111 @@ test = [ "uu_test" ]
|
||||
[dependencies]
|
||||
clap = { version = "2.33", features = ["wrap_help"] }
|
||||
lazy_static = { version="1.3" }
|
||||
textwrap = { version="=0.11.0", features=["term_size"] } # !maint: [2020-05-10; rivy] unstable crate using undocumented features; pinned currently, will review
|
||||
uucore = { version=">=0.0.9", package="uucore", path="src/uucore" }
|
||||
selinux = { version="0.2.1", optional = true }
|
||||
textwrap = { version="0.14", features=["terminal_size"] }
|
||||
uucore = { version=">=0.0.10", package="uucore", path="src/uucore" }
|
||||
selinux = { version="0.2.3", optional = true }
|
||||
# * uutils
|
||||
uu_test = { optional=true, version="0.0.7", package="uu_test", path="src/uu/test" }
|
||||
uu_test = { optional=true, version="0.0.8", package="uu_test", path="src/uu/test" }
|
||||
#
|
||||
arch = { optional=true, version="0.0.7", package="uu_arch", path="src/uu/arch" }
|
||||
base32 = { optional=true, version="0.0.7", package="uu_base32", path="src/uu/base32" }
|
||||
base64 = { optional=true, version="0.0.7", package="uu_base64", path="src/uu/base64" }
|
||||
basename = { optional=true, version="0.0.7", package="uu_basename", path="src/uu/basename" }
|
||||
basenc = { optional=true, version="0.0.7", package="uu_basenc", path="src/uu/basenc" }
|
||||
cat = { optional=true, version="0.0.7", package="uu_cat", path="src/uu/cat" }
|
||||
chcon = { optional=true, version="0.0.7", package="uu_chcon", path="src/uu/chcon" }
|
||||
chgrp = { optional=true, version="0.0.7", package="uu_chgrp", path="src/uu/chgrp" }
|
||||
chmod = { optional=true, version="0.0.7", package="uu_chmod", path="src/uu/chmod" }
|
||||
chown = { optional=true, version="0.0.7", package="uu_chown", path="src/uu/chown" }
|
||||
chroot = { optional=true, version="0.0.7", package="uu_chroot", path="src/uu/chroot" }
|
||||
cksum = { optional=true, version="0.0.7", package="uu_cksum", path="src/uu/cksum" }
|
||||
comm = { optional=true, version="0.0.7", package="uu_comm", path="src/uu/comm" }
|
||||
cp = { optional=true, version="0.0.7", package="uu_cp", path="src/uu/cp" }
|
||||
csplit = { optional=true, version="0.0.7", package="uu_csplit", path="src/uu/csplit" }
|
||||
cut = { optional=true, version="0.0.7", package="uu_cut", path="src/uu/cut" }
|
||||
date = { optional=true, version="0.0.7", package="uu_date", path="src/uu/date" }
|
||||
dd = { optional=true, version="0.0.7", package="uu_dd", path="src/uu/dd" }
|
||||
df = { optional=true, version="0.0.7", package="uu_df", path="src/uu/df" }
|
||||
dircolors= { optional=true, version="0.0.7", package="uu_dircolors", path="src/uu/dircolors" }
|
||||
dirname = { optional=true, version="0.0.7", package="uu_dirname", path="src/uu/dirname" }
|
||||
du = { optional=true, version="0.0.7", package="uu_du", path="src/uu/du" }
|
||||
echo = { optional=true, version="0.0.7", package="uu_echo", path="src/uu/echo" }
|
||||
env = { optional=true, version="0.0.7", package="uu_env", path="src/uu/env" }
|
||||
expand = { optional=true, version="0.0.7", package="uu_expand", path="src/uu/expand" }
|
||||
expr = { optional=true, version="0.0.7", package="uu_expr", path="src/uu/expr" }
|
||||
factor = { optional=true, version="0.0.7", package="uu_factor", path="src/uu/factor" }
|
||||
false = { optional=true, version="0.0.7", package="uu_false", path="src/uu/false" }
|
||||
fmt = { optional=true, version="0.0.7", package="uu_fmt", path="src/uu/fmt" }
|
||||
fold = { optional=true, version="0.0.7", package="uu_fold", path="src/uu/fold" }
|
||||
groups = { optional=true, version="0.0.7", package="uu_groups", path="src/uu/groups" }
|
||||
hashsum = { optional=true, version="0.0.7", package="uu_hashsum", path="src/uu/hashsum" }
|
||||
head = { optional=true, version="0.0.7", package="uu_head", path="src/uu/head" }
|
||||
hostid = { optional=true, version="0.0.7", package="uu_hostid", path="src/uu/hostid" }
|
||||
hostname = { optional=true, version="0.0.7", package="uu_hostname", path="src/uu/hostname" }
|
||||
id = { optional=true, version="0.0.7", package="uu_id", path="src/uu/id" }
|
||||
install = { optional=true, version="0.0.7", package="uu_install", path="src/uu/install" }
|
||||
join = { optional=true, version="0.0.7", package="uu_join", path="src/uu/join" }
|
||||
kill = { optional=true, version="0.0.7", package="uu_kill", path="src/uu/kill" }
|
||||
link = { optional=true, version="0.0.7", package="uu_link", path="src/uu/link" }
|
||||
ln = { optional=true, version="0.0.7", package="uu_ln", path="src/uu/ln" }
|
||||
ls = { optional=true, version="0.0.7", package="uu_ls", path="src/uu/ls" }
|
||||
logname = { optional=true, version="0.0.7", package="uu_logname", path="src/uu/logname" }
|
||||
mkdir = { optional=true, version="0.0.7", package="uu_mkdir", path="src/uu/mkdir" }
|
||||
mkfifo = { optional=true, version="0.0.7", package="uu_mkfifo", path="src/uu/mkfifo" }
|
||||
mknod = { optional=true, version="0.0.7", package="uu_mknod", path="src/uu/mknod" }
|
||||
mktemp = { optional=true, version="0.0.7", package="uu_mktemp", path="src/uu/mktemp" }
|
||||
more = { optional=true, version="0.0.7", package="uu_more", path="src/uu/more" }
|
||||
mv = { optional=true, version="0.0.7", package="uu_mv", path="src/uu/mv" }
|
||||
nice = { optional=true, version="0.0.7", package="uu_nice", path="src/uu/nice" }
|
||||
nl = { optional=true, version="0.0.7", package="uu_nl", path="src/uu/nl" }
|
||||
nohup = { optional=true, version="0.0.7", package="uu_nohup", path="src/uu/nohup" }
|
||||
nproc = { optional=true, version="0.0.7", package="uu_nproc", path="src/uu/nproc" }
|
||||
numfmt = { optional=true, version="0.0.7", package="uu_numfmt", path="src/uu/numfmt" }
|
||||
od = { optional=true, version="0.0.7", package="uu_od", path="src/uu/od" }
|
||||
paste = { optional=true, version="0.0.7", package="uu_paste", path="src/uu/paste" }
|
||||
pathchk = { optional=true, version="0.0.7", package="uu_pathchk", path="src/uu/pathchk" }
|
||||
pinky = { optional=true, version="0.0.7", package="uu_pinky", path="src/uu/pinky" }
|
||||
pr = { optional=true, version="0.0.7", package="uu_pr", path="src/uu/pr" }
|
||||
printenv = { optional=true, version="0.0.7", package="uu_printenv", path="src/uu/printenv" }
|
||||
printf = { optional=true, version="0.0.7", package="uu_printf", path="src/uu/printf" }
|
||||
ptx = { optional=true, version="0.0.7", package="uu_ptx", path="src/uu/ptx" }
|
||||
pwd = { optional=true, version="0.0.7", package="uu_pwd", path="src/uu/pwd" }
|
||||
readlink = { optional=true, version="0.0.7", package="uu_readlink", path="src/uu/readlink" }
|
||||
realpath = { optional=true, version="0.0.7", package="uu_realpath", path="src/uu/realpath" }
|
||||
relpath = { optional=true, version="0.0.7", package="uu_relpath", path="src/uu/relpath" }
|
||||
rm = { optional=true, version="0.0.7", package="uu_rm", path="src/uu/rm" }
|
||||
rmdir = { optional=true, version="0.0.7", package="uu_rmdir", path="src/uu/rmdir" }
|
||||
seq = { optional=true, version="0.0.7", package="uu_seq", path="src/uu/seq" }
|
||||
shred = { optional=true, version="0.0.7", package="uu_shred", path="src/uu/shred" }
|
||||
shuf = { optional=true, version="0.0.7", package="uu_shuf", path="src/uu/shuf" }
|
||||
sleep = { optional=true, version="0.0.7", package="uu_sleep", path="src/uu/sleep" }
|
||||
sort = { optional=true, version="0.0.7", package="uu_sort", path="src/uu/sort" }
|
||||
split = { optional=true, version="0.0.7", package="uu_split", path="src/uu/split" }
|
||||
stat = { optional=true, version="0.0.7", package="uu_stat", path="src/uu/stat" }
|
||||
stdbuf = { optional=true, version="0.0.7", package="uu_stdbuf", path="src/uu/stdbuf" }
|
||||
sum = { optional=true, version="0.0.7", package="uu_sum", path="src/uu/sum" }
|
||||
sync = { optional=true, version="0.0.7", package="uu_sync", path="src/uu/sync" }
|
||||
tac = { optional=true, version="0.0.7", package="uu_tac", path="src/uu/tac" }
|
||||
tail = { optional=true, version="0.0.7", package="uu_tail", path="src/uu/tail" }
|
||||
tee = { optional=true, version="0.0.7", package="uu_tee", path="src/uu/tee" }
|
||||
timeout = { optional=true, version="0.0.7", package="uu_timeout", path="src/uu/timeout" }
|
||||
touch = { optional=true, version="0.0.7", package="uu_touch", path="src/uu/touch" }
|
||||
tr = { optional=true, version="0.0.7", package="uu_tr", path="src/uu/tr" }
|
||||
true = { optional=true, version="0.0.7", package="uu_true", path="src/uu/true" }
|
||||
truncate = { optional=true, version="0.0.7", package="uu_truncate", path="src/uu/truncate" }
|
||||
tsort = { optional=true, version="0.0.7", package="uu_tsort", path="src/uu/tsort" }
|
||||
tty = { optional=true, version="0.0.7", package="uu_tty", path="src/uu/tty" }
|
||||
uname = { optional=true, version="0.0.7", package="uu_uname", path="src/uu/uname" }
|
||||
unexpand = { optional=true, version="0.0.7", package="uu_unexpand", path="src/uu/unexpand" }
|
||||
uniq = { optional=true, version="0.0.7", package="uu_uniq", path="src/uu/uniq" }
|
||||
unlink = { optional=true, version="0.0.7", package="uu_unlink", path="src/uu/unlink" }
|
||||
uptime = { optional=true, version="0.0.7", package="uu_uptime", path="src/uu/uptime" }
|
||||
users = { optional=true, version="0.0.7", package="uu_users", path="src/uu/users" }
|
||||
wc = { optional=true, version="0.0.7", package="uu_wc", path="src/uu/wc" }
|
||||
who = { optional=true, version="0.0.7", package="uu_who", path="src/uu/who" }
|
||||
whoami = { optional=true, version="0.0.7", package="uu_whoami", path="src/uu/whoami" }
|
||||
yes = { optional=true, version="0.0.7", package="uu_yes", path="src/uu/yes" }
|
||||
arch = { optional=true, version="0.0.8", package="uu_arch", path="src/uu/arch" }
|
||||
base32 = { optional=true, version="0.0.8", package="uu_base32", path="src/uu/base32" }
|
||||
base64 = { optional=true, version="0.0.8", package="uu_base64", path="src/uu/base64" }
|
||||
basename = { optional=true, version="0.0.8", package="uu_basename", path="src/uu/basename" }
|
||||
basenc = { optional=true, version="0.0.8", package="uu_basenc", path="src/uu/basenc" }
|
||||
cat = { optional=true, version="0.0.8", package="uu_cat", path="src/uu/cat" }
|
||||
chcon = { optional=true, version="0.0.8", package="uu_chcon", path="src/uu/chcon" }
|
||||
chgrp = { optional=true, version="0.0.8", package="uu_chgrp", path="src/uu/chgrp" }
|
||||
chmod = { optional=true, version="0.0.8", package="uu_chmod", path="src/uu/chmod" }
|
||||
chown = { optional=true, version="0.0.8", package="uu_chown", path="src/uu/chown" }
|
||||
chroot = { optional=true, version="0.0.8", package="uu_chroot", path="src/uu/chroot" }
|
||||
cksum = { optional=true, version="0.0.8", package="uu_cksum", path="src/uu/cksum" }
|
||||
comm = { optional=true, version="0.0.8", package="uu_comm", path="src/uu/comm" }
|
||||
cp = { optional=true, version="0.0.8", package="uu_cp", path="src/uu/cp" }
|
||||
csplit = { optional=true, version="0.0.8", package="uu_csplit", path="src/uu/csplit" }
|
||||
cut = { optional=true, version="0.0.8", package="uu_cut", path="src/uu/cut" }
|
||||
date = { optional=true, version="0.0.8", package="uu_date", path="src/uu/date" }
|
||||
dd = { optional=true, version="0.0.8", package="uu_dd", path="src/uu/dd" }
|
||||
df = { optional=true, version="0.0.8", package="uu_df", path="src/uu/df" }
|
||||
dircolors= { optional=true, version="0.0.8", package="uu_dircolors", path="src/uu/dircolors" }
|
||||
dirname = { optional=true, version="0.0.8", package="uu_dirname", path="src/uu/dirname" }
|
||||
du = { optional=true, version="0.0.8", package="uu_du", path="src/uu/du" }
|
||||
echo = { optional=true, version="0.0.8", package="uu_echo", path="src/uu/echo" }
|
||||
env = { optional=true, version="0.0.8", package="uu_env", path="src/uu/env" }
|
||||
expand = { optional=true, version="0.0.8", package="uu_expand", path="src/uu/expand" }
|
||||
expr = { optional=true, version="0.0.8", package="uu_expr", path="src/uu/expr" }
|
||||
factor = { optional=true, version="0.0.8", package="uu_factor", path="src/uu/factor" }
|
||||
false = { optional=true, version="0.0.8", package="uu_false", path="src/uu/false" }
|
||||
fmt = { optional=true, version="0.0.8", package="uu_fmt", path="src/uu/fmt" }
|
||||
fold = { optional=true, version="0.0.8", package="uu_fold", path="src/uu/fold" }
|
||||
groups = { optional=true, version="0.0.8", package="uu_groups", path="src/uu/groups" }
|
||||
hashsum = { optional=true, version="0.0.8", package="uu_hashsum", path="src/uu/hashsum" }
|
||||
head = { optional=true, version="0.0.8", package="uu_head", path="src/uu/head" }
|
||||
hostid = { optional=true, version="0.0.8", package="uu_hostid", path="src/uu/hostid" }
|
||||
hostname = { optional=true, version="0.0.8", package="uu_hostname", path="src/uu/hostname" }
|
||||
id = { optional=true, version="0.0.8", package="uu_id", path="src/uu/id" }
|
||||
install = { optional=true, version="0.0.8", package="uu_install", path="src/uu/install" }
|
||||
join = { optional=true, version="0.0.8", package="uu_join", path="src/uu/join" }
|
||||
kill = { optional=true, version="0.0.8", package="uu_kill", path="src/uu/kill" }
|
||||
link = { optional=true, version="0.0.8", package="uu_link", path="src/uu/link" }
|
||||
ln = { optional=true, version="0.0.8", package="uu_ln", path="src/uu/ln" }
|
||||
ls = { optional=true, version="0.0.8", package="uu_ls", path="src/uu/ls" }
|
||||
logname = { optional=true, version="0.0.8", package="uu_logname", path="src/uu/logname" }
|
||||
mkdir = { optional=true, version="0.0.8", package="uu_mkdir", path="src/uu/mkdir" }
|
||||
mkfifo = { optional=true, version="0.0.8", package="uu_mkfifo", path="src/uu/mkfifo" }
|
||||
mknod = { optional=true, version="0.0.8", package="uu_mknod", path="src/uu/mknod" }
|
||||
mktemp = { optional=true, version="0.0.8", package="uu_mktemp", path="src/uu/mktemp" }
|
||||
more = { optional=true, version="0.0.8", package="uu_more", path="src/uu/more" }
|
||||
mv = { optional=true, version="0.0.8", package="uu_mv", path="src/uu/mv" }
|
||||
nice = { optional=true, version="0.0.8", package="uu_nice", path="src/uu/nice" }
|
||||
nl = { optional=true, version="0.0.8", package="uu_nl", path="src/uu/nl" }
|
||||
nohup = { optional=true, version="0.0.8", package="uu_nohup", path="src/uu/nohup" }
|
||||
nproc = { optional=true, version="0.0.8", package="uu_nproc", path="src/uu/nproc" }
|
||||
numfmt = { optional=true, version="0.0.8", package="uu_numfmt", path="src/uu/numfmt" }
|
||||
od = { optional=true, version="0.0.8", package="uu_od", path="src/uu/od" }
|
||||
paste = { optional=true, version="0.0.8", package="uu_paste", path="src/uu/paste" }
|
||||
pathchk = { optional=true, version="0.0.8", package="uu_pathchk", path="src/uu/pathchk" }
|
||||
pinky = { optional=true, version="0.0.8", package="uu_pinky", path="src/uu/pinky" }
|
||||
pr = { optional=true, version="0.0.8", package="uu_pr", path="src/uu/pr" }
|
||||
printenv = { optional=true, version="0.0.8", package="uu_printenv", path="src/uu/printenv" }
|
||||
printf = { optional=true, version="0.0.8", package="uu_printf", path="src/uu/printf" }
|
||||
ptx = { optional=true, version="0.0.8", package="uu_ptx", path="src/uu/ptx" }
|
||||
pwd = { optional=true, version="0.0.8", package="uu_pwd", path="src/uu/pwd" }
|
||||
readlink = { optional=true, version="0.0.8", package="uu_readlink", path="src/uu/readlink" }
|
||||
realpath = { optional=true, version="0.0.8", package="uu_realpath", path="src/uu/realpath" }
|
||||
relpath = { optional=true, version="0.0.8", package="uu_relpath", path="src/uu/relpath" }
|
||||
rm = { optional=true, version="0.0.8", package="uu_rm", path="src/uu/rm" }
|
||||
rmdir = { optional=true, version="0.0.8", package="uu_rmdir", path="src/uu/rmdir" }
|
||||
runcon = { optional=true, version="0.0.8", package="uu_runcon", path="src/uu/runcon" }
|
||||
seq = { optional=true, version="0.0.8", package="uu_seq", path="src/uu/seq" }
|
||||
shred = { optional=true, version="0.0.8", package="uu_shred", path="src/uu/shred" }
|
||||
shuf = { optional=true, version="0.0.8", package="uu_shuf", path="src/uu/shuf" }
|
||||
sleep = { optional=true, version="0.0.8", package="uu_sleep", path="src/uu/sleep" }
|
||||
sort = { optional=true, version="0.0.8", package="uu_sort", path="src/uu/sort" }
|
||||
split = { optional=true, version="0.0.8", package="uu_split", path="src/uu/split" }
|
||||
stat = { optional=true, version="0.0.8", package="uu_stat", path="src/uu/stat" }
|
||||
stdbuf = { optional=true, version="0.0.8", package="uu_stdbuf", path="src/uu/stdbuf" }
|
||||
sum = { optional=true, version="0.0.8", package="uu_sum", path="src/uu/sum" }
|
||||
sync = { optional=true, version="0.0.8", package="uu_sync", path="src/uu/sync" }
|
||||
tac = { optional=true, version="0.0.8", package="uu_tac", path="src/uu/tac" }
|
||||
tail = { optional=true, version="0.0.8", package="uu_tail", path="src/uu/tail" }
|
||||
tee = { optional=true, version="0.0.8", package="uu_tee", path="src/uu/tee" }
|
||||
timeout = { optional=true, version="0.0.8", package="uu_timeout", path="src/uu/timeout" }
|
||||
touch = { optional=true, version="0.0.8", package="uu_touch", path="src/uu/touch" }
|
||||
tr = { optional=true, version="0.0.8", package="uu_tr", path="src/uu/tr" }
|
||||
true = { optional=true, version="0.0.8", package="uu_true", path="src/uu/true" }
|
||||
truncate = { optional=true, version="0.0.8", package="uu_truncate", path="src/uu/truncate" }
|
||||
tsort = { optional=true, version="0.0.8", package="uu_tsort", path="src/uu/tsort" }
|
||||
tty = { optional=true, version="0.0.8", package="uu_tty", path="src/uu/tty" }
|
||||
uname = { optional=true, version="0.0.8", package="uu_uname", path="src/uu/uname" }
|
||||
unexpand = { optional=true, version="0.0.8", package="uu_unexpand", path="src/uu/unexpand" }
|
||||
uniq = { optional=true, version="0.0.8", package="uu_uniq", path="src/uu/uniq" }
|
||||
unlink = { optional=true, version="0.0.8", package="uu_unlink", path="src/uu/unlink" }
|
||||
uptime = { optional=true, version="0.0.8", package="uu_uptime", path="src/uu/uptime" }
|
||||
users = { optional=true, version="0.0.8", package="uu_users", path="src/uu/users" }
|
||||
wc = { optional=true, version="0.0.8", package="uu_wc", path="src/uu/wc" }
|
||||
who = { optional=true, version="0.0.8", package="uu_who", path="src/uu/who" }
|
||||
whoami = { optional=true, version="0.0.8", package="uu_whoami", path="src/uu/whoami" }
|
||||
yes = { optional=true, version="0.0.8", package="uu_yes", path="src/uu/yes" }
|
||||
|
||||
# this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)"
|
||||
# factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" }
|
||||
@@ -358,7 +366,6 @@ conv = "0.3"
|
||||
filetime = "0.2"
|
||||
glob = "0.3.0"
|
||||
libc = "0.2"
|
||||
nix = "0.20.0"
|
||||
pretty_assertions = "0.7.2"
|
||||
rand = "0.7"
|
||||
regex = "1.0"
|
||||
@@ -366,12 +373,16 @@ sha1 = { version="0.6", features=["std"] }
|
||||
tempfile = "3.2.0"
|
||||
time = "0.1"
|
||||
unindent = "0.1"
|
||||
uucore = { version=">=0.0.9", package="uucore", path="src/uucore", features=["entries", "process"] }
|
||||
uucore = { version=">=0.0.10", package="uucore", path="src/uucore", features=["entries", "process"] }
|
||||
walkdir = "2.2"
|
||||
atty = "0.2"
|
||||
|
||||
[target.'cfg(unix)'.dev-dependencies]
|
||||
[target.'cfg(target_os = "linux")'.dev-dependencies]
|
||||
rlimit = "0.4.0"
|
||||
|
||||
[target.'cfg(unix)'.dev-dependencies]
|
||||
nix = "0.20.0"
|
||||
|
||||
rust-users = { version="0.10", package="users" }
|
||||
unix_socket = "0.5.0"
|
||||
|
||||
|
||||
@@ -1,3 +1,29 @@
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
The source of the documentation is available on:
|
||||
|
||||
https://uutils.github.io/coreutils-docs/coreutils/
|
||||
|
||||
The documentation is updated everyday on this repository:
|
||||
|
||||
https://github.com/uutils/coreutils-docs
|
||||
|
||||
Running GNU tests
|
||||
-----------------
|
||||
|
||||
<!-- spell-checker:ignore gnulib -->
|
||||
|
||||
- Check out https://github.com/coreutils/coreutils next to your fork as gnu
|
||||
- Check out https://github.com/coreutils/gnulib next to your fork as gnulib
|
||||
- Rename the checkout of your fork to uutils
|
||||
|
||||
At the end you should have uutils, gnu and gnulib checked out next to each other.
|
||||
|
||||
- Run `cd uutils && ./util/build-gnu.sh && cd ..` to get everything ready (this may take a while)
|
||||
- Finally, you can run `tests with bash uutils/util/run-gnu-test.sh <test>`. Instead of `<test>` insert the test you want to run, e.g. `tests/misc/wc-proc`.
|
||||
|
||||
|
||||
Code Coverage Report Generation
|
||||
---------------------------------
|
||||
|
||||
|
||||
+3
-1
@@ -157,7 +157,8 @@ UNIX_PROGS := \
|
||||
who
|
||||
|
||||
SELINUX_PROGS := \
|
||||
chcon
|
||||
chcon \
|
||||
runcon
|
||||
|
||||
ifneq ($(OS),Windows_NT)
|
||||
PROGS := $(PROGS) $(UNIX_PROGS)
|
||||
@@ -216,6 +217,7 @@ TEST_PROGS := \
|
||||
realpath \
|
||||
rm \
|
||||
rmdir \
|
||||
runcon \
|
||||
seq \
|
||||
sort \
|
||||
split \
|
||||
|
||||
@@ -365,8 +365,8 @@ To contribute to uutils, please see [CONTRIBUTING](CONTRIBUTING.md).
|
||||
|
||||
| Done | Semi-Done | To Do |
|
||||
|-----------|-----------|--------|
|
||||
| arch | cp | runcon |
|
||||
| base32 | date | stty |
|
||||
| arch | cp | stty |
|
||||
| base32 | date | |
|
||||
| base64 | dd | |
|
||||
| basename | df | |
|
||||
| basenc | expr | |
|
||||
@@ -426,6 +426,7 @@ To contribute to uutils, please see [CONTRIBUTING](CONTRIBUTING.md).
|
||||
| relpath | | |
|
||||
| rm | | |
|
||||
| rmdir | | |
|
||||
| runcon | | |
|
||||
| seq | | |
|
||||
| shred | | |
|
||||
| shuf | | |
|
||||
|
||||
+20
-10
@@ -10,10 +10,12 @@ use clap::Arg;
|
||||
use clap::Shell;
|
||||
use std::cmp;
|
||||
use std::collections::hash_map::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::ffi::OsString;
|
||||
use std::io::{self, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process;
|
||||
use uucore::display::Quotable;
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
@@ -70,18 +72,27 @@ fn main() {
|
||||
Some(OsString::from(*util))
|
||||
} else {
|
||||
// unmatched binary name => regard as multi-binary container and advance argument list
|
||||
uucore::set_utility_is_second_arg();
|
||||
args.next()
|
||||
};
|
||||
|
||||
// 0th argument equals util name?
|
||||
if let Some(util_os) = util_name {
|
||||
let util = util_os.as_os_str().to_string_lossy();
|
||||
fn not_found(util: &OsStr) -> ! {
|
||||
println!("{}: function/utility not found", util.maybe_quote());
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let util = match util_os.to_str() {
|
||||
Some(util) => util,
|
||||
None => not_found(&util_os),
|
||||
};
|
||||
|
||||
if util == "completion" {
|
||||
gen_completions(args, utils);
|
||||
}
|
||||
|
||||
match utils.get(&util[..]) {
|
||||
match utils.get(util) {
|
||||
Some(&(uumain, _)) => {
|
||||
process::exit(uumain((vec![util_os].into_iter()).chain(args)));
|
||||
}
|
||||
@@ -89,9 +100,12 @@ fn main() {
|
||||
if util == "--help" || util == "-h" {
|
||||
// see if they want help on a specific util
|
||||
if let Some(util_os) = args.next() {
|
||||
let util = util_os.as_os_str().to_string_lossy();
|
||||
let util = match util_os.to_str() {
|
||||
Some(util) => util,
|
||||
None => not_found(&util_os),
|
||||
};
|
||||
|
||||
match utils.get(&util[..]) {
|
||||
match utils.get(util) {
|
||||
Some(&(uumain, _)) => {
|
||||
let code = uumain(
|
||||
(vec![util_os, OsString::from("--help")].into_iter())
|
||||
@@ -100,17 +114,13 @@ fn main() {
|
||||
io::stdout().flush().expect("could not flush stdout");
|
||||
process::exit(code);
|
||||
}
|
||||
None => {
|
||||
println!("{}: function/utility not found", util);
|
||||
process::exit(1);
|
||||
}
|
||||
None => not_found(&util_os),
|
||||
}
|
||||
}
|
||||
usage(&utils, binary_as_util);
|
||||
process::exit(0);
|
||||
} else {
|
||||
println!("{}: function/utility not found", util);
|
||||
process::exit(1);
|
||||
not_found(&util_os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uu_arch"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
authors = ["uutils developers"]
|
||||
license = "MIT"
|
||||
description = "arch ~ (uutils) display machine architecture"
|
||||
@@ -17,8 +17,8 @@ path = "src/arch.rs"
|
||||
[dependencies]
|
||||
platform-info = "0.1"
|
||||
clap = { version = "2.33", features = ["wrap_help"] }
|
||||
uucore = { version=">=0.0.9", package="uucore", path="../../uucore" }
|
||||
uucore_procs = { version=">=0.0.6", package="uucore_procs", path="../../uucore_procs" }
|
||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
|
||||
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
||||
|
||||
[[bin]]
|
||||
name = "arch"
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
||||
use platform_info::*;
|
||||
|
||||
use clap::{crate_version, App};
|
||||
@@ -27,7 +24,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
}
|
||||
|
||||
pub fn uu_app() -> App<'static, 'static> {
|
||||
App::new(executable!())
|
||||
App::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.after_help(SUMMARY)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uu_base32"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
authors = ["uutils developers"]
|
||||
license = "MIT"
|
||||
description = "base32 ~ (uutils) decode/encode input (base32-encoding)"
|
||||
@@ -16,9 +16,13 @@ path = "src/base32.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "2.33", features = ["wrap_help"] }
|
||||
uucore = { version=">=0.0.9", package="uucore", path="../../uucore", features = ["encoding"] }
|
||||
uucore_procs = { version=">=0.0.6", package="uucore_procs", path="../../uucore_procs" }
|
||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features = ["encoding"] }
|
||||
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
||||
|
||||
[[bin]]
|
||||
name = "base32"
|
||||
path = "src/main.rs"
|
||||
|
||||
[package.metadata.cargo-udeps.ignore]
|
||||
# Necessary for "make all"
|
||||
normal = ["uucore_procs"]
|
||||
|
||||
+10
-21
@@ -5,13 +5,10 @@
|
||||
// For the full copyright and license information, please view the LICENSE file
|
||||
// that was distributed with this source code.
|
||||
|
||||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
||||
use std::io::{stdin, Read};
|
||||
|
||||
use clap::App;
|
||||
use uucore::encoding::Format;
|
||||
use uucore::{encoding::Format, error::UResult};
|
||||
|
||||
pub mod base_common;
|
||||
|
||||
@@ -24,27 +21,22 @@ static ABOUT: &str = "
|
||||
to attempt to recover from any other non-alphabet bytes in the
|
||||
encoded stream.
|
||||
";
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
||||
|
||||
fn get_usage() -> String {
|
||||
format!("{0} [OPTION]... [FILE]", executable!())
|
||||
fn usage() -> String {
|
||||
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
||||
}
|
||||
|
||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||
#[uucore_procs::gen_uumain]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let format = Format::Base32;
|
||||
let usage = get_usage();
|
||||
let name = executable!();
|
||||
let usage = usage();
|
||||
|
||||
let config_result: Result<base_common::Config, String> =
|
||||
base_common::parse_base_cmd_args(args, name, VERSION, ABOUT, &usage);
|
||||
let config = config_result.unwrap_or_else(|s| crash!(BASE_CMD_PARSE_ERROR, "{}", s));
|
||||
let config: base_common::Config = base_common::parse_base_cmd_args(args, ABOUT, &usage)?;
|
||||
|
||||
// Create a reference to stdin so we can return a locked stdin from
|
||||
// parse_base_cmd_args
|
||||
let stdin_raw = stdin();
|
||||
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw);
|
||||
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw)?;
|
||||
|
||||
base_common::handle_input(
|
||||
&mut input,
|
||||
@@ -52,12 +44,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||
config.wrap_cols,
|
||||
config.ignore_garbage,
|
||||
config.decode,
|
||||
name,
|
||||
);
|
||||
|
||||
0
|
||||
)
|
||||
}
|
||||
|
||||
pub fn uu_app() -> App<'static, 'static> {
|
||||
base_common::base_app(executable!(), VERSION, ABOUT)
|
||||
base_common::base_app(ABOUT)
|
||||
}
|
||||
|
||||
@@ -9,14 +9,18 @@
|
||||
|
||||
use std::io::{stdout, Read, Write};
|
||||
|
||||
use uucore::display::Quotable;
|
||||
use uucore::encoding::{wrap_print, Data, Format};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::InvalidEncodingHandling;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Stdin};
|
||||
use std::path::Path;
|
||||
|
||||
use clap::{App, Arg};
|
||||
use clap::{crate_version, App, Arg};
|
||||
|
||||
pub static BASE_CMD_PARSE_ERROR: i32 = 1;
|
||||
|
||||
// Config.
|
||||
pub struct Config {
|
||||
@@ -34,14 +38,14 @@ pub mod options {
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn from(app_name: &str, options: &clap::ArgMatches) -> Result<Config, String> {
|
||||
pub fn from(options: &clap::ArgMatches) -> UResult<Config> {
|
||||
let file: Option<String> = match options.values_of(options::FILE) {
|
||||
Some(mut values) => {
|
||||
let name = values.next().unwrap();
|
||||
if let Some(extra_op) = values.next() {
|
||||
return Err(format!(
|
||||
"extra operand '{}'\nTry '{} --help' for more information.",
|
||||
extra_op, app_name
|
||||
return Err(UUsageError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
format!("extra operand {}", extra_op.quote(),),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -49,7 +53,10 @@ impl Config {
|
||||
None
|
||||
} else {
|
||||
if !Path::exists(Path::new(name)) {
|
||||
return Err(format!("{}: No such file or directory", name));
|
||||
return Err(USimpleError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
format!("{}: No such file or directory", name.maybe_quote()),
|
||||
));
|
||||
}
|
||||
Some(name.to_owned())
|
||||
}
|
||||
@@ -60,8 +67,12 @@ impl Config {
|
||||
let cols = options
|
||||
.value_of(options::WRAP)
|
||||
.map(|num| {
|
||||
num.parse::<usize>()
|
||||
.map_err(|_| format!("invalid wrap size: '{}'", num))
|
||||
num.parse::<usize>().map_err(|_| {
|
||||
USimpleError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
format!("invalid wrap size: {}", num.quote()),
|
||||
)
|
||||
})
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
@@ -74,23 +85,17 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_base_cmd_args(
|
||||
args: impl uucore::Args,
|
||||
name: &str,
|
||||
version: &str,
|
||||
about: &str,
|
||||
usage: &str,
|
||||
) -> Result<Config, String> {
|
||||
let app = base_app(name, version, about).usage(usage);
|
||||
pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult<Config> {
|
||||
let app = base_app(about).usage(usage);
|
||||
let arg_list = args
|
||||
.collect_str(InvalidEncodingHandling::ConvertLossy)
|
||||
.accept_any();
|
||||
Config::from(name, &app.get_matches_from(arg_list))
|
||||
Config::from(&app.get_matches_from(arg_list))
|
||||
}
|
||||
|
||||
pub fn base_app<'a>(name: &str, version: &'a str, about: &'a str) -> App<'static, 'a> {
|
||||
App::new(name)
|
||||
.version(version)
|
||||
pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> {
|
||||
App::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(about)
|
||||
// Format arguments.
|
||||
.arg(
|
||||
@@ -119,14 +124,15 @@ pub fn base_app<'a>(name: &str, version: &'a str, about: &'a str) -> App<'static
|
||||
.arg(Arg::with_name(options::FILE).index(1).multiple(true))
|
||||
}
|
||||
|
||||
pub fn get_input<'a>(config: &Config, stdin_ref: &'a Stdin) -> Box<dyn Read + 'a> {
|
||||
pub fn get_input<'a>(config: &Config, stdin_ref: &'a Stdin) -> UResult<Box<dyn Read + 'a>> {
|
||||
match &config.to_read {
|
||||
Some(name) => {
|
||||
let file_buf = safe_unwrap!(File::open(Path::new(name)));
|
||||
Box::new(BufReader::new(file_buf)) // as Box<dyn Read>
|
||||
let file_buf =
|
||||
File::open(Path::new(name)).map_err_context(|| name.maybe_quote().to_string())?;
|
||||
Ok(Box::new(BufReader::new(file_buf))) // as Box<dyn Read>
|
||||
}
|
||||
None => {
|
||||
Box::new(stdin_ref.lock()) // as Box<dyn Read>
|
||||
Ok(Box::new(stdin_ref.lock())) // as Box<dyn Read>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,8 +143,7 @@ pub fn handle_input<R: Read>(
|
||||
line_wrap: Option<usize>,
|
||||
ignore_garbage: bool,
|
||||
decode: bool,
|
||||
name: &str,
|
||||
) {
|
||||
) -> UResult<()> {
|
||||
let mut data = Data::new(input, format).ignore_garbage(ignore_garbage);
|
||||
if let Some(wrap) = line_wrap {
|
||||
data = data.line_wrap(wrap);
|
||||
@@ -148,28 +153,25 @@ pub fn handle_input<R: Read>(
|
||||
match data.encode() {
|
||||
Ok(s) => {
|
||||
wrap_print(&data, s);
|
||||
Ok(())
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"{}: error: invalid input (length must be multiple of 4 characters)",
|
||||
name
|
||||
);
|
||||
exit!(1)
|
||||
}
|
||||
Err(_) => Err(USimpleError::new(
|
||||
1,
|
||||
"error: invalid input (length must be multiple of 4 characters)",
|
||||
)),
|
||||
}
|
||||
} else {
|
||||
match data.decode() {
|
||||
Ok(s) => {
|
||||
// Silent the warning as we want to the error message
|
||||
#[allow(clippy::question_mark)]
|
||||
if stdout().write_all(&s).is_err() {
|
||||
// on windows console, writing invalid utf8 returns an error
|
||||
eprintln!("{}: error: Cannot write non-utf8 data", name);
|
||||
exit!(1)
|
||||
return Err(USimpleError::new(1, "error: cannot write non-utf8 data"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!("{}: error: invalid input", name);
|
||||
exit!(1)
|
||||
}
|
||||
Err(_) => Err(USimpleError::new(1, "error: invalid input")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uu_base64"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
authors = ["uutils developers"]
|
||||
license = "MIT"
|
||||
description = "base64 ~ (uutils) decode/encode input (base64-encoding)"
|
||||
@@ -16,10 +16,14 @@ path = "src/base64.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "2.33", features = ["wrap_help"] }
|
||||
uucore = { version=">=0.0.9", package="uucore", path="../../uucore", features = ["encoding"] }
|
||||
uucore_procs = { version=">=0.0.6", package="uucore_procs", path="../../uucore_procs" }
|
||||
uu_base32 = { version=">=0.0.6", package="uu_base32", path="../base32"}
|
||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features = ["encoding"] }
|
||||
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
||||
uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"}
|
||||
|
||||
[[bin]]
|
||||
name = "base64"
|
||||
path = "src/main.rs"
|
||||
|
||||
[package.metadata.cargo-udeps.ignore]
|
||||
# Necessary for "make all"
|
||||
normal = ["uucore_procs"]
|
||||
|
||||
+10
-20
@@ -6,13 +6,10 @@
|
||||
// For the full copyright and license information, please view the LICENSE file
|
||||
// that was distributed with this source code.
|
||||
|
||||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
||||
use uu_base32::base_common;
|
||||
pub use uu_base32::uu_app;
|
||||
|
||||
use uucore::encoding::Format;
|
||||
use uucore::{encoding::Format, error::UResult};
|
||||
|
||||
use std::io::{stdin, Read};
|
||||
|
||||
@@ -25,26 +22,22 @@ static ABOUT: &str = "
|
||||
to attempt to recover from any other non-alphabet bytes in the
|
||||
encoded stream.
|
||||
";
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
static BASE_CMD_PARSE_ERROR: i32 = 1;
|
||||
|
||||
fn get_usage() -> String {
|
||||
format!("{0} [OPTION]... [FILE]", executable!())
|
||||
fn usage() -> String {
|
||||
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
|
||||
}
|
||||
|
||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||
#[uucore_procs::gen_uumain]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let format = Format::Base64;
|
||||
let usage = get_usage();
|
||||
let name = executable!();
|
||||
let config_result: Result<base_common::Config, String> =
|
||||
base_common::parse_base_cmd_args(args, name, VERSION, ABOUT, &usage);
|
||||
let config = config_result.unwrap_or_else(|s| crash!(BASE_CMD_PARSE_ERROR, "{}", s));
|
||||
let usage = usage();
|
||||
|
||||
let config: base_common::Config = base_common::parse_base_cmd_args(args, ABOUT, &usage)?;
|
||||
|
||||
// Create a reference to stdin so we can return a locked stdin from
|
||||
// parse_base_cmd_args
|
||||
let stdin_raw = stdin();
|
||||
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw);
|
||||
let mut input: Box<dyn Read> = base_common::get_input(&config, &stdin_raw)?;
|
||||
|
||||
base_common::handle_input(
|
||||
&mut input,
|
||||
@@ -52,8 +45,5 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||
config.wrap_cols,
|
||||
config.ignore_garbage,
|
||||
config.decode,
|
||||
name,
|
||||
);
|
||||
|
||||
0
|
||||
)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user