diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index bdc964c42..97369a8e7 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -154,6 +154,33 @@ jobs: env: RUSTFLAGS: '-Awarnings' + busybox_test: + name: Busybox test suite + runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + job: + - { os: ubuntu-latest } + steps: + - uses: actions/checkout@v1 + - name: Install `rust` toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + profile: minimal # minimal component installation (ie, no documentation) + - name: "prepare busytest" + shell: bash + run: | + make prepare-busytest + - name: "run busybox testsuite" + shell: bash + run: | + bindir=$(pwd)/target/debug + cd tmp/busybox-*/testsuite + S=$(bindir=$bindir ./runtest) && printf "%s\n" "$S" || { printf "%s\n" "$S" | grep "FAIL:" | sed -e "s/FAIL: /::warning ::Test failure:/g" ; } + build: name: Build runs-on: ${{ matrix.job.os }} diff --git a/.travis.yml b/.travis.yml index 65658179f..3cd7db130 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: - rust: nightly fast_finish: true include: - - rust: 1.32.0 + - rust: 1.33.0 env: FEATURES=unix # - rust: stable # os: linux diff --git a/Cargo.lock b/Cargo.lock index 89279dc18..9d9fb6c24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,3 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. [[package]] name = "advapi32-sys" version = "0.2.0" @@ -61,11 +59,6 @@ name = "bit-vec" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bitflags" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "1.2.1" @@ -86,7 +79,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -97,7 +90,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -185,7 +178,7 @@ dependencies = [ [[package]] name = "coreutils" -version = "0.0.3" +version = "0.0.4" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.61 (registry+https://github.com/rust-lang/crates.io-index)", @@ -195,7 +188,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,102 +199,102 @@ dependencies = [ "unindent 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "users 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uu_arch 0.0.3", - "uu_base32 0.0.3", - "uu_base64 0.0.3", - "uu_basename 0.0.3", - "uu_cat 0.0.3", - "uu_chgrp 0.0.3", - "uu_chmod 0.0.3", - "uu_chown 0.0.3", - "uu_chroot 0.0.3", - "uu_cksum 0.0.3", - "uu_comm 0.0.3", - "uu_cp 0.0.3", - "uu_csplit 0.0.3", - "uu_cut 0.0.3", - "uu_date 0.0.3", - "uu_df 0.0.3", - "uu_dircolors 0.0.3", - "uu_dirname 0.0.3", - "uu_du 0.0.3", - "uu_echo 0.0.3", - "uu_env 0.0.3", - "uu_expand 0.0.3", - "uu_expr 0.0.3", - "uu_factor 0.0.3", - "uu_false 0.0.3", - "uu_fmt 0.0.3", - "uu_fold 0.0.3", - "uu_groups 0.0.3", - "uu_hashsum 0.0.3", - "uu_head 0.0.3", - "uu_hostid 0.0.3", - "uu_hostname 0.0.3", - "uu_id 0.0.3", - "uu_install 0.0.3", - "uu_join 0.0.3", - "uu_kill 0.0.3", - "uu_link 0.0.3", - "uu_ln 0.0.3", - "uu_logname 0.0.3", - "uu_ls 0.0.3", - "uu_mkdir 0.0.3", - "uu_mkfifo 0.0.3", - "uu_mknod 0.0.3", - "uu_mktemp 0.0.3", - "uu_more 0.0.3", - "uu_mv 0.0.3", - "uu_nice 0.0.3", - "uu_nl 0.0.3", - "uu_nohup 0.0.3", - "uu_nproc 0.0.3", - "uu_numfmt 0.0.3", - "uu_od 0.0.3", - "uu_paste 0.0.3", - "uu_pathchk 0.0.3", - "uu_pinky 0.0.3", - "uu_printenv 0.0.3", - "uu_printf 0.0.3", - "uu_ptx 0.0.3", - "uu_pwd 0.0.3", - "uu_readlink 0.0.3", - "uu_realpath 0.0.3", - "uu_relpath 0.0.3", - "uu_rm 0.0.3", - "uu_rmdir 0.0.3", - "uu_seq 0.0.3", - "uu_shred 0.0.3", - "uu_shuf 0.0.3", - "uu_sleep 0.0.3", - "uu_sort 0.0.3", - "uu_split 0.0.3", - "uu_stat 0.0.3", - "uu_stdbuf 0.0.3", - "uu_sum 0.0.3", - "uu_sync 0.0.3", - "uu_tac 0.0.3", - "uu_tail 0.0.3", - "uu_tee 0.0.3", - "uu_test 0.0.3", - "uu_timeout 0.0.3", - "uu_touch 0.0.3", - "uu_tr 0.0.3", - "uu_true 0.0.3", - "uu_truncate 0.0.3", - "uu_tsort 0.0.3", - "uu_tty 0.0.3", - "uu_uname 0.0.3", - "uu_unexpand 0.0.3", - "uu_uniq 0.0.3", - "uu_unlink 0.0.3", - "uu_uptime 0.0.3", - "uu_users 0.0.3", - "uu_wc 0.0.3", - "uu_who 0.0.3", - "uu_whoami 0.0.3", - "uu_yes 0.0.3", - "uucore 0.0.6", + "uu_arch 0.0.4", + "uu_base32 0.0.4", + "uu_base64 0.0.4", + "uu_basename 0.0.4", + "uu_cat 0.0.4", + "uu_chgrp 0.0.4", + "uu_chmod 0.0.4", + "uu_chown 0.0.4", + "uu_chroot 0.0.4", + "uu_cksum 0.0.4", + "uu_comm 0.0.4", + "uu_cp 0.0.4", + "uu_csplit 0.0.4", + "uu_cut 0.0.4", + "uu_date 0.0.4", + "uu_df 0.0.4", + "uu_dircolors 0.0.4", + "uu_dirname 0.0.4", + "uu_du 0.0.4", + "uu_echo 0.0.4", + "uu_env 0.0.4", + "uu_expand 0.0.4", + "uu_expr 0.0.4", + "uu_factor 0.0.4", + "uu_false 0.0.4", + "uu_fmt 0.0.4", + "uu_fold 0.0.4", + "uu_groups 0.0.4", + "uu_hashsum 0.0.4", + "uu_head 0.0.4", + "uu_hostid 0.0.4", + "uu_hostname 0.0.4", + "uu_id 0.0.4", + "uu_install 0.0.4", + "uu_join 0.0.4", + "uu_kill 0.0.4", + "uu_link 0.0.4", + "uu_ln 0.0.4", + "uu_logname 0.0.4", + "uu_ls 0.0.4", + "uu_mkdir 0.0.4", + "uu_mkfifo 0.0.4", + "uu_mknod 0.0.4", + "uu_mktemp 0.0.4", + "uu_more 0.0.4", + "uu_mv 0.0.4", + "uu_nice 0.0.4", + "uu_nl 0.0.4", + "uu_nohup 0.0.4", + "uu_nproc 0.0.4", + "uu_numfmt 0.0.4", + "uu_od 0.0.4", + "uu_paste 0.0.4", + "uu_pathchk 0.0.4", + "uu_pinky 0.0.4", + "uu_printenv 0.0.4", + "uu_printf 0.0.4", + "uu_ptx 0.0.4", + "uu_pwd 0.0.4", + "uu_readlink 0.0.4", + "uu_realpath 0.0.4", + "uu_relpath 0.0.4", + "uu_rm 0.0.4", + "uu_rmdir 0.0.4", + "uu_seq 0.0.4", + "uu_shred 0.0.4", + "uu_shuf 0.0.4", + "uu_sleep 0.0.4", + "uu_sort 0.0.4", + "uu_split 0.0.4", + "uu_stat 0.0.4", + "uu_stdbuf 0.0.4", + "uu_sum 0.0.4", + "uu_sync 0.0.4", + "uu_tac 0.0.4", + "uu_tail 0.0.4", + "uu_tee 0.0.4", + "uu_test 0.0.4", + "uu_timeout 0.0.4", + "uu_touch 0.0.4", + "uu_tr 0.0.4", + "uu_true 0.0.4", + "uu_truncate 0.0.4", + "uu_tsort 0.0.4", + "uu_tty 0.0.4", + "uu_uname 0.0.4", + "uu_unexpand 0.0.4", + "uu_uniq 0.0.4", + "uu_unlink 0.0.4", + "uu_uptime 0.0.4", + "uu_users 0.0.4", + "uu_wc 0.0.4", + "uu_who 0.0.4", + "uu_whoami 0.0.4", + "uu_yes 0.0.4", + "uucore 0.0.7", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -344,7 +337,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -359,7 +352,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -399,19 +392,19 @@ dependencies = [ "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "plotters 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", "serde_cbor 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.62 (registry+https://github.com/rust-lang/crates.io-index)", - "tinytemplate 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", + "tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -430,7 +423,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -439,44 +432,42 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-epoch 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "loom 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-utils" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "loom 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -502,7 +493,7 @@ name = "digest" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -521,7 +512,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -555,25 +546,13 @@ name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "generator" -version = "0.6.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.61 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustversion 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "generic-array" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -673,10 +652,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.47" +version = "0.3.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -706,16 +685,6 @@ dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "loom" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "generator 0.6.24 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "match_cfg" version = "0.1.0" @@ -752,17 +721,6 @@ dependencies = [ "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nix" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nix" version = "0.13.1" @@ -863,15 +821,6 @@ name = "pkg-config" version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "platform-info" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "platform-info" version = "0.1.0" @@ -889,8 +838,8 @@ dependencies = [ "num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "plotters-backend 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "plotters-svg 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.47 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1042,7 +991,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-channel 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1070,13 +1019,12 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.3" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1089,7 +1037,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1118,11 +1066,6 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustversion" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "ryu" version = "1.0.5" @@ -1136,11 +1079,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "scopeguard" version = "1.1.0" @@ -1161,7 +1099,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1170,27 +1108,27 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.62" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1207,7 +1145,7 @@ dependencies = [ "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1218,7 +1156,7 @@ dependencies = [ "block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1236,7 +1174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.60" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1321,7 +1259,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1344,16 +1282,16 @@ dependencies = [ [[package]] name = "tinytemplate" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.62 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1396,115 +1334,115 @@ dependencies = [ [[package]] name = "uu_arch" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "platform-info 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "platform-info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_base32" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_base64" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_basename" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_cat" -version = "0.0.3" +version = "0.0.4" dependencies = [ "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_chgrp" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_chmod" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_chown" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_chroot" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_cksum" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_comm" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_cp" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "ioctl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1513,115 +1451,115 @@ dependencies = [ [[package]] name = "uu_csplit" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_cut" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_date" -version = "0.0.3" +version = "0.0.4" dependencies = [ "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_df" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_dircolors" -version = "0.0.3" +version = "0.0.4" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_dirname" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_du" -version = "0.0.3" +version = "0.0.4" dependencies = [ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_echo" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_env" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_expand" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_expr" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "onig 4.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_factor" -version = "0.0.3" +version = "0.0.4" dependencies = [ "criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1630,49 +1568,49 @@ dependencies = [ "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_false" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_fmt" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_fold" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_groups" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_hashsum" -version = "0.0.3" +version = "0.0.4" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1680,114 +1618,115 @@ dependencies = [ "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "md5 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_head" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_hostid" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_hostname" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "hostname 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_id" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_install" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_join" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_kill" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_link" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_ln" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_logname" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_ls" -version = "0.0.3" +version = "0.0.4" dependencies = [ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1797,575 +1736,576 @@ dependencies = [ "termsize 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_mkdir" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_mkfifo" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_mknod" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_mktemp" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_more" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_mv" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "fs_extra 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_nice" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_nl" -version = "0.0.3" +version = "0.0.4" dependencies = [ "aho-corasick 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_nohup" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_nproc" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_numfmt" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_od" -version = "0.0.3" +version = "0.0.4" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_paste" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_pathchk" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_pinky" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_printenv" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_printf" -version = "0.0.3" +version = "0.0.4" dependencies = [ "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_ptx" -version = "0.0.3" +version = "0.0.4" dependencies = [ "aho-corasick 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_pwd" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_readlink" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_realpath" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_relpath" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_rm" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_rmdir" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_seq" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_shred" -version = "0.0.3" +version = "0.0.4" dependencies = [ "filetime 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_shuf" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_sleep" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_sort" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_split" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_stat" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_stdbuf" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uu_stdbuf_libstdbuf 0.0.3", - "uucore 0.0.6", + "uu_stdbuf_libstdbuf 0.0.4", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_stdbuf_libstdbuf" -version = "0.0.3" +version = "0.0.4" dependencies = [ "cpp 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "cpp_build 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_sum" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_sync" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_tac" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_tail" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_tee" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_test" -version = "0.0.3" +version = "0.0.4" dependencies = [ "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_timeout" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_touch" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_tr" -version = "0.0.3" +version = "0.0.4" dependencies = [ "bit-set 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_true" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_truncate" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_tsort" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_tty" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_uname" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "platform-info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_unexpand" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_uniq" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_unlink" -version = "0.0.3" +version = "0.0.4" dependencies = [ "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_uptime" -version = "0.0.3" +version = "0.0.4" dependencies = [ "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_users" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_wc" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_who" -version = "0.0.3" +version = "0.0.4" dependencies = [ - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uu_whoami" -version = "0.0.3" +version = "0.0.4" dependencies = [ "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uu_yes" -version = "0.0.3" +version = "0.0.4" dependencies = [ "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uucore 0.0.6", + "uucore 0.0.7", "uucore_procs 0.0.5", ] [[package]] name = "uucore" -version = "0.0.6" +version = "0.0.7" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dunce 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2373,7 +2313,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "platform-info 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "platform-info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2386,7 +2326,7 @@ version = "0.0.5" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2416,16 +2356,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.70" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.70" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2433,43 +2373,43 @@ dependencies = [ "log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.70" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.70" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.70" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "web-sys" -version = "0.3.47" +version = "0.3.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "js-sys 0.3.47 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2534,7 +2474,6 @@ dependencies = [ "checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" "checksum bit-set 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" "checksum bit-vec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" @@ -2563,9 +2502,9 @@ dependencies = [ "checksum criterion-plot 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" "checksum crossbeam-channel 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" "checksum crossbeam-deque 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" -"checksum crossbeam-epoch 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d60ab4a8dba064f2fbb5aa270c28da5cf4bbd0e72dae1140a6b0353a779dbe00" -"checksum crossbeam-utils 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bae8f328835f8f5a6ceb6a7842a7f2d0c03692adb5c889347235d59194731fe3" -"checksum csv 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" +"checksum crossbeam-epoch 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +"checksum crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +"checksum csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" @@ -2578,8 +2517,7 @@ dependencies = [ "checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" "checksum fs_extra 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum generator 0.6.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a9fed24fd1e18827652b4d55652899a1e9da8e54d91624dc3437a5bc3a9f9a9c" -"checksum generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fceb69994e330afed50c93524be68c42fa898c2d9fd4ee8da03bd7363acd26f2" +"checksum generic-array 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2297fb0e3ea512e380da24b52dca3924028f59df5e3a17a18f81d8349ca7ebe" "checksum getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" "checksum getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" @@ -2594,12 +2532,11 @@ dependencies = [ "checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" "checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" "checksum itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" -"checksum js-sys 0.3.47 (registry+https://github.com/rust-lang/crates.io-index)" = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" +"checksum js-sys 0.3.48 (registry+https://github.com/rust-lang/crates.io-index)" = "dc9f84f9b115ce7843d60706df1422a916680bfdfcbdb0447c5614ff9d7e4d78" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.85 (registry+https://github.com/rust-lang/crates.io-index)" = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" "checksum log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -"checksum loom 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d44c73b4636e497b4917eb21c33539efa3816741a2d3ff26c6316f1b529481a4" "checksum match_cfg 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum md5 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48" @@ -2607,7 +2544,6 @@ dependencies = [ "checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" "checksum memoffset 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" "checksum nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b" -"checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum num-integer 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" "checksum num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" @@ -2620,7 +2556,6 @@ dependencies = [ "checksum paste 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" "checksum paste-impl 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" "checksum pkg-config 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" -"checksum platform-info 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f2fd076acdc7a98374de6e300bf3af675997225bef21aecac2219553f04dd7e8" "checksum platform-info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ea9cd21d89bffb387b6c7363d23bead0807be9de676c671b474dd29e7436d3" "checksum plotters 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" "checksum plotters-backend 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" @@ -2645,30 +2580,28 @@ dependencies = [ "checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" "checksum redox_syscall 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" "checksum redox_termios 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f" -"checksum regex 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +"checksum regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" "checksum regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -"checksum regex-syntax 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +"checksum regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)" = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" "checksum remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rustversion 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" "checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" -"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)" = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +"checksum serde 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)" = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" "checksum serde_cbor 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" -"checksum serde_derive 1.0.123 (registry+https://github.com/rust-lang/crates.io-index)" = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" -"checksum serde_json 1.0.62 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" +"checksum serde_derive 1.0.124 (registry+https://github.com/rust-lang/crates.io-index)" = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" +"checksum serde_json 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)" = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a" "checksum sha3 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26405905b6a56a94c60109cfda62610507ac14a65be531f5767dec5c5a8dd6a0" "checksum smallvec 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum syn 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)" = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +"checksum syn 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term_grid 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "230d3e804faaed5a39b08319efb797783df2fd9671b39b7596490cb486d702cf" "checksum term_size 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" @@ -2679,8 +2612,8 @@ dependencies = [ "checksum thiserror-impl 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" "checksum thread_local 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tinytemplate 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" -"checksum typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +"checksum tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +"checksum typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" "checksum unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" @@ -2691,12 +2624,12 @@ dependencies = [ "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -"checksum wasm-bindgen 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" -"checksum wasm-bindgen-backend 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" -"checksum wasm-bindgen-macro 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" -"checksum wasm-bindgen-macro-support 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" -"checksum wasm-bindgen-shared 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" -"checksum web-sys 0.3.47 (registry+https://github.com/rust-lang/crates.io-index)" = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" +"checksum wasm-bindgen 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7" +"checksum wasm-bindgen-backend 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "5b7d8b6942b8bb3a9b0e73fc79b98095a27de6fa247615e59d096754a3bc2aa8" +"checksum wasm-bindgen-macro 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "e5ac38da8ef716661f0f36c0d8320b89028efe10c7c0afde65baffb496ce0d3b" +"checksum wasm-bindgen-macro-support 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e" +"checksum wasm-bindgen-shared 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "7d6f8ec44822dd71f5f221a5847fb34acd9060535c1211b70a05844c0f6383b1" +"checksum web-sys 0.3.48 (registry+https://github.com/rust-lang/crates.io-index)" = "ec600b26223b2948cedfde2a0aa6756dcf1fef616f43d7b3097aaf53a6c4d92b" "checksum wild 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "035793abb854745033f01a07647a79831eba29ec0be377205f2a25b0aa830020" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" diff --git a/Cargo.toml b/Cargo.toml index 219f571e8..9b55abe5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "coreutils" -version = "0.0.3" # "0.0.3.1" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust" @@ -226,104 +226,104 @@ test = [ "uu_test" ] [dependencies] 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.6", package="uucore", path="src/uucore" } +uucore = { version=">=0.0.7", package="uucore", path="src/uucore" } # * uutils -uu_test = { optional=true, version="0.0.3", package="uu_test", path="src/uu/test" } +uu_test = { optional=true, version="0.0.4", package="uu_test", path="src/uu/test" } # -arch = { optional=true, version="0.0.3", package="uu_arch", path="src/uu/arch" } -base32 = { optional=true, version="0.0.3", package="uu_base32", path="src/uu/base32" } -base64 = { optional=true, version="0.0.3", package="uu_base64", path="src/uu/base64" } -basename = { optional=true, version="0.0.3", package="uu_basename", path="src/uu/basename" } -cat = { optional=true, version="0.0.3", package="uu_cat", path="src/uu/cat" } -chgrp = { optional=true, version="0.0.3", package="uu_chgrp", path="src/uu/chgrp" } -chmod = { optional=true, version="0.0.3", package="uu_chmod", path="src/uu/chmod" } -chown = { optional=true, version="0.0.3", package="uu_chown", path="src/uu/chown" } -chroot = { optional=true, version="0.0.3", package="uu_chroot", path="src/uu/chroot" } -cksum = { optional=true, version="0.0.3", package="uu_cksum", path="src/uu/cksum" } -comm = { optional=true, version="0.0.3", package="uu_comm", path="src/uu/comm" } -cp = { optional=true, version="0.0.3", package="uu_cp", path="src/uu/cp" } -csplit = { optional=true, version="0.0.3", package="uu_csplit", path="src/uu/csplit" } -cut = { optional=true, version="0.0.3", package="uu_cut", path="src/uu/cut" } -date = { optional=true, version="0.0.3", package="uu_date", path="src/uu/date" } -df = { optional=true, version="0.0.3", package="uu_df", path="src/uu/df" } -dircolors= { optional=true, version="0.0.3", package="uu_dircolors", path="src/uu/dircolors" } -dirname = { optional=true, version="0.0.3", package="uu_dirname", path="src/uu/dirname" } -du = { optional=true, version="0.0.3", package="uu_du", path="src/uu/du" } -echo = { optional=true, version="0.0.3", package="uu_echo", path="src/uu/echo" } -env = { optional=true, version="0.0.3", package="uu_env", path="src/uu/env" } -expand = { optional=true, version="0.0.3", package="uu_expand", path="src/uu/expand" } -expr = { optional=true, version="0.0.3", package="uu_expr", path="src/uu/expr" } -factor = { optional=true, version="0.0.3", package="uu_factor", path="src/uu/factor" } -false = { optional=true, version="0.0.3", package="uu_false", path="src/uu/false" } -fmt = { optional=true, version="0.0.3", package="uu_fmt", path="src/uu/fmt" } -fold = { optional=true, version="0.0.3", package="uu_fold", path="src/uu/fold" } -groups = { optional=true, version="0.0.3", package="uu_groups", path="src/uu/groups" } -hashsum = { optional=true, version="0.0.3", package="uu_hashsum", path="src/uu/hashsum" } -head = { optional=true, version="0.0.3", package="uu_head", path="src/uu/head" } -hostid = { optional=true, version="0.0.3", package="uu_hostid", path="src/uu/hostid" } -hostname = { optional=true, version="0.0.3", package="uu_hostname", path="src/uu/hostname" } -id = { optional=true, version="0.0.3", package="uu_id", path="src/uu/id" } -install = { optional=true, version="0.0.3", package="uu_install", path="src/uu/install" } -join = { optional=true, version="0.0.3", package="uu_join", path="src/uu/join" } -kill = { optional=true, version="0.0.3", package="uu_kill", path="src/uu/kill" } -link = { optional=true, version="0.0.3", package="uu_link", path="src/uu/link" } -ln = { optional=true, version="0.0.3", package="uu_ln", path="src/uu/ln" } -ls = { optional=true, version="0.0.3", package="uu_ls", path="src/uu/ls" } -logname = { optional=true, version="0.0.3", package="uu_logname", path="src/uu/logname" } -mkdir = { optional=true, version="0.0.3", package="uu_mkdir", path="src/uu/mkdir" } -mkfifo = { optional=true, version="0.0.3", package="uu_mkfifo", path="src/uu/mkfifo" } -mknod = { optional=true, version="0.0.3", package="uu_mknod", path="src/uu/mknod" } -mktemp = { optional=true, version="0.0.3", package="uu_mktemp", path="src/uu/mktemp" } -more = { optional=true, version="0.0.3", package="uu_more", path="src/uu/more" } -mv = { optional=true, version="0.0.3", package="uu_mv", path="src/uu/mv" } -nice = { optional=true, version="0.0.3", package="uu_nice", path="src/uu/nice" } -nl = { optional=true, version="0.0.3", package="uu_nl", path="src/uu/nl" } -nohup = { optional=true, version="0.0.3", package="uu_nohup", path="src/uu/nohup" } -nproc = { optional=true, version="0.0.3", package="uu_nproc", path="src/uu/nproc" } -numfmt = { optional=true, version="0.0.3", package="uu_numfmt", path="src/uu/numfmt" } -od = { optional=true, version="0.0.3", package="uu_od", path="src/uu/od" } -paste = { optional=true, version="0.0.3", package="uu_paste", path="src/uu/paste" } -pathchk = { optional=true, version="0.0.3", package="uu_pathchk", path="src/uu/pathchk" } -pinky = { optional=true, version="0.0.3", package="uu_pinky", path="src/uu/pinky" } -printenv = { optional=true, version="0.0.3", package="uu_printenv", path="src/uu/printenv" } -printf = { optional=true, version="0.0.3", package="uu_printf", path="src/uu/printf" } -ptx = { optional=true, version="0.0.3", package="uu_ptx", path="src/uu/ptx" } -pwd = { optional=true, version="0.0.3", package="uu_pwd", path="src/uu/pwd" } -readlink = { optional=true, version="0.0.3", package="uu_readlink", path="src/uu/readlink" } -realpath = { optional=true, version="0.0.3", package="uu_realpath", path="src/uu/realpath" } -relpath = { optional=true, version="0.0.3", package="uu_relpath", path="src/uu/relpath" } -rm = { optional=true, version="0.0.3", package="uu_rm", path="src/uu/rm" } -rmdir = { optional=true, version="0.0.3", package="uu_rmdir", path="src/uu/rmdir" } -seq = { optional=true, version="0.0.3", package="uu_seq", path="src/uu/seq" } -shred = { optional=true, version="0.0.3", package="uu_shred", path="src/uu/shred" } -shuf = { optional=true, version="0.0.3", package="uu_shuf", path="src/uu/shuf" } -sleep = { optional=true, version="0.0.3", package="uu_sleep", path="src/uu/sleep" } -sort = { optional=true, version="0.0.3", package="uu_sort", path="src/uu/sort" } -split = { optional=true, version="0.0.3", package="uu_split", path="src/uu/split" } -stat = { optional=true, version="0.0.3", package="uu_stat", path="src/uu/stat" } -stdbuf = { optional=true, version="0.0.3", package="uu_stdbuf", path="src/uu/stdbuf" } -sum = { optional=true, version="0.0.3", package="uu_sum", path="src/uu/sum" } -sync = { optional=true, version="0.0.3", package="uu_sync", path="src/uu/sync" } -tac = { optional=true, version="0.0.3", package="uu_tac", path="src/uu/tac" } -tail = { optional=true, version="0.0.3", package="uu_tail", path="src/uu/tail" } -tee = { optional=true, version="0.0.3", package="uu_tee", path="src/uu/tee" } -timeout = { optional=true, version="0.0.3", package="uu_timeout", path="src/uu/timeout" } -touch = { optional=true, version="0.0.3", package="uu_touch", path="src/uu/touch" } -tr = { optional=true, version="0.0.3", package="uu_tr", path="src/uu/tr" } -true = { optional=true, version="0.0.3", package="uu_true", path="src/uu/true" } -truncate = { optional=true, version="0.0.3", package="uu_truncate", path="src/uu/truncate" } -tsort = { optional=true, version="0.0.3", package="uu_tsort", path="src/uu/tsort" } -tty = { optional=true, version="0.0.3", package="uu_tty", path="src/uu/tty" } -uname = { optional=true, version="0.0.3", package="uu_uname", path="src/uu/uname" } -unexpand = { optional=true, version="0.0.3", package="uu_unexpand", path="src/uu/unexpand" } -uniq = { optional=true, version="0.0.3", package="uu_uniq", path="src/uu/uniq" } -unlink = { optional=true, version="0.0.3", package="uu_unlink", path="src/uu/unlink" } -uptime = { optional=true, version="0.0.3", package="uu_uptime", path="src/uu/uptime" } -users = { optional=true, version="0.0.3", package="uu_users", path="src/uu/users" } -wc = { optional=true, version="0.0.3", package="uu_wc", path="src/uu/wc" } -who = { optional=true, version="0.0.3", package="uu_who", path="src/uu/who" } -whoami = { optional=true, version="0.0.3", package="uu_whoami", path="src/uu/whoami" } -yes = { optional=true, version="0.0.3", package="uu_yes", path="src/uu/yes" } +arch = { optional=true, version="0.0.4", package="uu_arch", path="src/uu/arch" } +base32 = { optional=true, version="0.0.4", package="uu_base32", path="src/uu/base32" } +base64 = { optional=true, version="0.0.4", package="uu_base64", path="src/uu/base64" } +basename = { optional=true, version="0.0.4", package="uu_basename", path="src/uu/basename" } +cat = { optional=true, version="0.0.4", package="uu_cat", path="src/uu/cat" } +chgrp = { optional=true, version="0.0.4", package="uu_chgrp", path="src/uu/chgrp" } +chmod = { optional=true, version="0.0.4", package="uu_chmod", path="src/uu/chmod" } +chown = { optional=true, version="0.0.4", package="uu_chown", path="src/uu/chown" } +chroot = { optional=true, version="0.0.4", package="uu_chroot", path="src/uu/chroot" } +cksum = { optional=true, version="0.0.4", package="uu_cksum", path="src/uu/cksum" } +comm = { optional=true, version="0.0.4", package="uu_comm", path="src/uu/comm" } +cp = { optional=true, version="0.0.4", package="uu_cp", path="src/uu/cp" } +csplit = { optional=true, version="0.0.4", package="uu_csplit", path="src/uu/csplit" } +cut = { optional=true, version="0.0.4", package="uu_cut", path="src/uu/cut" } +date = { optional=true, version="0.0.4", package="uu_date", path="src/uu/date" } +df = { optional=true, version="0.0.4", package="uu_df", path="src/uu/df" } +dircolors= { optional=true, version="0.0.4", package="uu_dircolors", path="src/uu/dircolors" } +dirname = { optional=true, version="0.0.4", package="uu_dirname", path="src/uu/dirname" } +du = { optional=true, version="0.0.4", package="uu_du", path="src/uu/du" } +echo = { optional=true, version="0.0.4", package="uu_echo", path="src/uu/echo" } +env = { optional=true, version="0.0.4", package="uu_env", path="src/uu/env" } +expand = { optional=true, version="0.0.4", package="uu_expand", path="src/uu/expand" } +expr = { optional=true, version="0.0.4", package="uu_expr", path="src/uu/expr" } +factor = { optional=true, version="0.0.4", package="uu_factor", path="src/uu/factor" } +false = { optional=true, version="0.0.4", package="uu_false", path="src/uu/false" } +fmt = { optional=true, version="0.0.4", package="uu_fmt", path="src/uu/fmt" } +fold = { optional=true, version="0.0.4", package="uu_fold", path="src/uu/fold" } +groups = { optional=true, version="0.0.4", package="uu_groups", path="src/uu/groups" } +hashsum = { optional=true, version="0.0.4", package="uu_hashsum", path="src/uu/hashsum" } +head = { optional=true, version="0.0.4", package="uu_head", path="src/uu/head" } +hostid = { optional=true, version="0.0.4", package="uu_hostid", path="src/uu/hostid" } +hostname = { optional=true, version="0.0.4", package="uu_hostname", path="src/uu/hostname" } +id = { optional=true, version="0.0.4", package="uu_id", path="src/uu/id" } +install = { optional=true, version="0.0.4", package="uu_install", path="src/uu/install" } +join = { optional=true, version="0.0.4", package="uu_join", path="src/uu/join" } +kill = { optional=true, version="0.0.4", package="uu_kill", path="src/uu/kill" } +link = { optional=true, version="0.0.4", package="uu_link", path="src/uu/link" } +ln = { optional=true, version="0.0.4", package="uu_ln", path="src/uu/ln" } +ls = { optional=true, version="0.0.4", package="uu_ls", path="src/uu/ls" } +logname = { optional=true, version="0.0.4", package="uu_logname", path="src/uu/logname" } +mkdir = { optional=true, version="0.0.4", package="uu_mkdir", path="src/uu/mkdir" } +mkfifo = { optional=true, version="0.0.4", package="uu_mkfifo", path="src/uu/mkfifo" } +mknod = { optional=true, version="0.0.4", package="uu_mknod", path="src/uu/mknod" } +mktemp = { optional=true, version="0.0.4", package="uu_mktemp", path="src/uu/mktemp" } +more = { optional=true, version="0.0.4", package="uu_more", path="src/uu/more" } +mv = { optional=true, version="0.0.4", package="uu_mv", path="src/uu/mv" } +nice = { optional=true, version="0.0.4", package="uu_nice", path="src/uu/nice" } +nl = { optional=true, version="0.0.4", package="uu_nl", path="src/uu/nl" } +nohup = { optional=true, version="0.0.4", package="uu_nohup", path="src/uu/nohup" } +nproc = { optional=true, version="0.0.4", package="uu_nproc", path="src/uu/nproc" } +numfmt = { optional=true, version="0.0.4", package="uu_numfmt", path="src/uu/numfmt" } +od = { optional=true, version="0.0.4", package="uu_od", path="src/uu/od" } +paste = { optional=true, version="0.0.4", package="uu_paste", path="src/uu/paste" } +pathchk = { optional=true, version="0.0.4", package="uu_pathchk", path="src/uu/pathchk" } +pinky = { optional=true, version="0.0.4", package="uu_pinky", path="src/uu/pinky" } +printenv = { optional=true, version="0.0.4", package="uu_printenv", path="src/uu/printenv" } +printf = { optional=true, version="0.0.4", package="uu_printf", path="src/uu/printf" } +ptx = { optional=true, version="0.0.4", package="uu_ptx", path="src/uu/ptx" } +pwd = { optional=true, version="0.0.4", package="uu_pwd", path="src/uu/pwd" } +readlink = { optional=true, version="0.0.4", package="uu_readlink", path="src/uu/readlink" } +realpath = { optional=true, version="0.0.4", package="uu_realpath", path="src/uu/realpath" } +relpath = { optional=true, version="0.0.4", package="uu_relpath", path="src/uu/relpath" } +rm = { optional=true, version="0.0.4", package="uu_rm", path="src/uu/rm" } +rmdir = { optional=true, version="0.0.4", package="uu_rmdir", path="src/uu/rmdir" } +seq = { optional=true, version="0.0.4", package="uu_seq", path="src/uu/seq" } +shred = { optional=true, version="0.0.4", package="uu_shred", path="src/uu/shred" } +shuf = { optional=true, version="0.0.4", package="uu_shuf", path="src/uu/shuf" } +sleep = { optional=true, version="0.0.4", package="uu_sleep", path="src/uu/sleep" } +sort = { optional=true, version="0.0.4", package="uu_sort", path="src/uu/sort" } +split = { optional=true, version="0.0.4", package="uu_split", path="src/uu/split" } +stat = { optional=true, version="0.0.4", package="uu_stat", path="src/uu/stat" } +stdbuf = { optional=true, version="0.0.4", package="uu_stdbuf", path="src/uu/stdbuf" } +sum = { optional=true, version="0.0.4", package="uu_sum", path="src/uu/sum" } +sync = { optional=true, version="0.0.4", package="uu_sync", path="src/uu/sync" } +tac = { optional=true, version="0.0.4", package="uu_tac", path="src/uu/tac" } +tail = { optional=true, version="0.0.4", package="uu_tail", path="src/uu/tail" } +tee = { optional=true, version="0.0.4", package="uu_tee", path="src/uu/tee" } +timeout = { optional=true, version="0.0.4", package="uu_timeout", path="src/uu/timeout" } +touch = { optional=true, version="0.0.4", package="uu_touch", path="src/uu/touch" } +tr = { optional=true, version="0.0.4", package="uu_tr", path="src/uu/tr" } +true = { optional=true, version="0.0.4", package="uu_true", path="src/uu/true" } +truncate = { optional=true, version="0.0.4", package="uu_truncate", path="src/uu/truncate" } +tsort = { optional=true, version="0.0.4", package="uu_tsort", path="src/uu/tsort" } +tty = { optional=true, version="0.0.4", package="uu_tty", path="src/uu/tty" } +uname = { optional=true, version="0.0.4", package="uu_uname", path="src/uu/uname" } +unexpand = { optional=true, version="0.0.4", package="uu_unexpand", path="src/uu/unexpand" } +uniq = { optional=true, version="0.0.4", package="uu_uniq", path="src/uu/uniq" } +unlink = { optional=true, version="0.0.4", package="uu_unlink", path="src/uu/unlink" } +uptime = { optional=true, version="0.0.4", package="uu_uptime", path="src/uu/uptime" } +users = { optional=true, version="0.0.4", package="uu_users", path="src/uu/users" } +wc = { optional=true, version="0.0.4", package="uu_wc", path="src/uu/wc" } +who = { optional=true, version="0.0.4", package="uu_who", path="src/uu/who" } +whoami = { optional=true, version="0.0.4", package="uu_whoami", path="src/uu/whoami" } +yes = { optional=true, version="0.0.4", package="uu_yes", path="src/uu/yes" } # # * pinned transitive dependencies pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`) @@ -346,7 +346,7 @@ sha1 = { version="0.6", features=["std"] } tempfile = "= 3.1.0" time = "0.1" unindent = "0.1" -uucore = { version=">=0.0.6", package="uucore", path="src/uucore", features=["entries"] } +uucore = { version=">=0.0.7", package="uucore", path="src/uucore", features=["entries"] } [target.'cfg(unix)'.dev-dependencies] rust-users = { version="0.10", package="users" } diff --git a/GNUmakefile b/GNUmakefile index 28044f5f6..c4c9cbe8b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -41,7 +41,7 @@ PKG_BUILDDIR := $(BUILDDIR)/deps DOCSDIR := $(BASEDIR)/docs BUSYBOX_ROOT := $(BASEDIR)/tmp -BUSYBOX_VER := 1.24.1 +BUSYBOX_VER := 1.32.1 BUSYBOX_SRC := $(BUSYBOX_ROOT)/busybox-$(BUSYBOX_VER) # Possible programs @@ -228,7 +228,7 @@ endif define TEST_BUSYBOX test_busybox_$(1): - (cd $(BUSYBOX_SRC)/testsuite && bindir=$(BUILDDIR) ./runtest $(RUNTEST_ARGS) $(1) ) + -(cd $(BUSYBOX_SRC)/testsuite && bindir=$(BUILDDIR) ./runtest $(RUNTEST_ARGS) $(1)) endef # Output names @@ -276,9 +276,11 @@ $(BUILDDIR)/.config: $(BASEDIR)/.busybox-config # Test under the busybox testsuite $(BUILDDIR)/busybox: busybox-src build-uutils $(BUILDDIR)/.config - cp $(BUILDDIR)/uutils $(BUILDDIR)/busybox; \ + cp $(BUILDDIR)/coreutils $(BUILDDIR)/busybox; \ chmod +x $@; +prepare-busytest: $(BUILDDIR)/busybox + ifeq ($(EXES),) busytest: else diff --git a/README.md b/README.md index 694141702..9d25a1120 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ uutils coreutils ================ +[![Crates.io](https://img.shields.io/crates/v/coreutils.svg)](https://crates.io/crates/coreutils) [![Discord](https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat)](https://discord.gg/wQVJbvJ) [![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uutils/coreutils/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fuutils%2Fcoreutils.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fuutils%2Fcoreutils?ref=badge_shield) [![LOC](https://tokei.rs/b1/github/uutils/coreutils?category=code)](https://github.com/Aaronepower/tokei) [![dependency status](https://deps.rs/repo/github/uutils/coreutils/status.svg)](https://deps.rs/repo/github/uutils/coreutils) [![Build Status](https://api.travis-ci.org/uutils/coreutils.svg?branch=master)](https://travis-ci.org/uutils/coreutils) -[![Build Status (Windows)](https://ci.appveyor.com/api/projects/status/787ltcxgy86r20le?svg=true)](https://ci.appveyor.com/project/Arcterus/coreutils) [![Build Status (FreeBSD)](https://api.cirrus-ci.com/github/uutils/coreutils.svg)](https://cirrus-ci.com/github/uutils/coreutils/master) [![codecov](https://codecov.io/gh/uutils/coreutils/branch/master/graph/badge.svg)](https://codecov.io/gh/uutils/coreutils) @@ -115,7 +114,7 @@ Installation Instructions Likewise, installing can simply be done using: ```bash -$ cargo install +$ cargo install --path . ``` This command will install uutils into Cargo's *bin* folder (*e.g.* `$HOME/.cargo/bin`). @@ -380,4 +379,4 @@ License uutils is licensed under the MIT License - see the `LICENSE` file for details -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fuutils%2Fcoreutils.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fuutils%2Fcoreutils?ref=badge_large) +GNU Coreutils is licensed under the GPL 3.0 or later. diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index b172edbd3..7fc494020 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -19,7 +19,7 @@ include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); fn usage(utils: &UtilityMap, name: &str) { println!("{} {} (multi-call binary)\n", name, VERSION); println!("Usage: {} [function [arguments...]]\n", name); - println!("Currently defined functions/utilities:\n"); + println!("Currently defined functions:\n"); #[allow(clippy::map_clone)] let mut utils: Vec<&str> = utils.keys().map(|&s| s).collect(); utils.sort_unstable(); diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index 664392ba4..4ca0fbda7 100644 --- a/src/uu/arch/Cargo.toml +++ b/src/uu/arch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_arch" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "arch ~ (uutils) display machine architecture" @@ -15,8 +15,8 @@ edition = "2018" path = "src/arch.rs" [dependencies] -platform-info = "0.0.1" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +platform-info = "0.1" +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index 57ce64759..0abb718c8 100644 --- a/src/uu/base32/Cargo.toml +++ b/src/uu/base32/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base32" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "base32 ~ (uutils) decode/encode input (base32-encoding)" @@ -15,7 +15,7 @@ edition = "2018" path = "src/base32.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features = ["encoding"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/base64/Cargo.toml b/src/uu/base64/Cargo.toml index da3ed16e6..eef9b1ec3 100644 --- a/src/uu/base64/Cargo.toml +++ b/src/uu/base64/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base64" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "base64 ~ (uutils) decode/encode input (base64-encoding)" @@ -15,7 +15,7 @@ edition = "2018" path = "src/base64.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features = ["encoding"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index 9a06d4acd..218d9eb08 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basename" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "basename ~ (uutils) display PATHNAME with leading directory components removed" @@ -15,7 +15,7 @@ edition = "2018" path = "src/basename.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 49f8b6761..415477588 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cat" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "cat ~ (uutils) concatenate and display input" @@ -16,7 +16,7 @@ path = "src/cat.rs" [dependencies] quick-error = "1.2.3" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index bcae7b436..60f9d6370 100644 --- a/src/uu/chgrp/Cargo.toml +++ b/src/uu/chgrp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chgrp" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "chgrp ~ (uutils) change the group ownership of FILE" @@ -15,7 +15,7 @@ edition = "2018" path = "src/chgrp.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index 6829dab62..41b73d8a6 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chmod" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "chmod ~ (uutils) change mode of FILE" @@ -16,7 +16,7 @@ path = "src/chmod.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs", "mode"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs", "mode"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index e0bbf759c..f2d21ef88 100644 --- a/src/uu/chown/Cargo.toml +++ b/src/uu/chown/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chown" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "chown ~ (uutils) change the ownership of FILE" @@ -17,7 +17,7 @@ path = "src/chown.rs" [dependencies] clap = "2.33" glob = "0.3.0" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 5ad82872b..42010de03 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -27,20 +27,30 @@ use std::path::Path; static ABOUT: &str = "change file owner and group"; static VERSION: &str = env!("CARGO_PKG_VERSION"); -static OPT_CHANGES: &str = "changes"; -static OPT_DEREFERENCE: &str = "dereference"; -static OPT_NO_DEREFERENCE: &str = "no-dereference"; -static OPT_FROM: &str = "from"; -static OPT_PRESERVE_ROOT: &str = "preserve-root"; -static OPT_NO_PRESERVE_ROOT: &str = "no-preserve-root"; -static OPT_QUIET: &str = "quiet"; -static OPT_RECURSIVE: &str = "recursive"; -static OPT_REFERENCE: &str = "reference"; -static OPT_SILENT: &str = "silent"; -static OPT_TRAVERSE: &str = "H"; -static OPT_NO_TRAVERSE: &str = "P"; -static OPT_TRAVERSE_EVERY: &str = "L"; -static OPT_VERBOSE: &str = "verbose"; +pub mod options { + pub mod verbosity { + pub static CHANGES: &str = "changes"; + pub static QUIET: &str = "quiet"; + pub static SILENT: &str = "silent"; + pub static VERBOSE: &str = "verbose"; + } + pub mod preserve_root { + pub static PRESERVE: &str = "preserve-root"; + pub static NO_PRESERVE: &str = "no-preserve-root"; + } + pub mod dereference { + pub static DEREFERENCE: &str = "dereference"; + pub static NO_DEREFERENCE: &str = "no-dereference"; + } + pub static FROM: &str = "from"; + pub static RECURSIVE: &str = "recursive"; + pub mod traverse { + pub static TRAVERSE: &str = "H"; + pub static NO_TRAVERSE: &str = "P"; + pub static EVERY: &str = "L"; + } + pub static REFERENCE: &str = "reference"; +} static ARG_OWNER: &str = "owner"; static ARG_FILES: &str = "files"; @@ -66,80 +76,80 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .arg( - Arg::with_name(OPT_CHANGES) + Arg::with_name(options::verbosity::CHANGES) .short("c") - .long(OPT_CHANGES) + .long(options::verbosity::CHANGES) .help("like verbose but report only when a change is made"), ) - .arg(Arg::with_name(OPT_DEREFERENCE).long(OPT_DEREFERENCE).help( + .arg(Arg::with_name(options::dereference::DEREFERENCE).long(options::dereference::DEREFERENCE).help( "affect the referent of each symbolic link (this is the default), rather than the symbolic link itself", )) .arg( - Arg::with_name(OPT_NO_DEREFERENCE) + Arg::with_name(options::dereference::NO_DEREFERENCE) .short("h") - .long(OPT_NO_DEREFERENCE) + .long(options::dereference::NO_DEREFERENCE) .help( "affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)", ), ) .arg( - Arg::with_name(OPT_FROM) - .long(OPT_FROM) + Arg::with_name(options::FROM) + .long(options::FROM) .help( "change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute", ) .value_name("CURRENT_OWNER:CURRENT_GROUP"), ) .arg( - Arg::with_name(OPT_PRESERVE_ROOT) - .long(OPT_PRESERVE_ROOT) + Arg::with_name(options::preserve_root::PRESERVE) + .long(options::preserve_root::PRESERVE) .help("fail to operate recursively on '/'"), ) .arg( - Arg::with_name(OPT_NO_PRESERVE_ROOT) - .long(OPT_NO_PRESERVE_ROOT) + Arg::with_name(options::preserve_root::NO_PRESERVE) + .long(options::preserve_root::NO_PRESERVE) .help("do not treat '/' specially (the default)"), ) .arg( - Arg::with_name(OPT_QUIET) - .long(OPT_QUIET) + Arg::with_name(options::verbosity::QUIET) + .long(options::verbosity::QUIET) .help("suppress most error messages"), ) .arg( - Arg::with_name(OPT_RECURSIVE) + Arg::with_name(options::RECURSIVE) .short("R") - .long(OPT_RECURSIVE) + .long(options::RECURSIVE) .help("operate on files and directories recursively"), ) .arg( - Arg::with_name(OPT_REFERENCE) - .long(OPT_REFERENCE) + Arg::with_name(options::REFERENCE) + .long(options::REFERENCE) .help("use RFILE's owner and group rather than specifying OWNER:GROUP values") .value_name("RFILE") .min_values(1), ) - .arg(Arg::with_name(OPT_SILENT).short("f").long(OPT_SILENT)) + .arg(Arg::with_name(options::verbosity::SILENT).short("f").long(options::verbosity::SILENT)) .arg( - Arg::with_name(OPT_TRAVERSE) - .short(OPT_TRAVERSE) + Arg::with_name(options::traverse::TRAVERSE) + .short(options::traverse::TRAVERSE) .help("if a command line argument is a symbolic link to a directory, traverse it") - .overrides_with_all(&[OPT_TRAVERSE_EVERY, OPT_NO_TRAVERSE]), + .overrides_with_all(&[options::traverse::EVERY, options::traverse::NO_TRAVERSE]), ) .arg( - Arg::with_name(OPT_TRAVERSE_EVERY) - .short(OPT_TRAVERSE_EVERY) + Arg::with_name(options::traverse::EVERY) + .short(options::traverse::EVERY) .help("traverse every symbolic link to a directory encountered") - .overrides_with_all(&[OPT_TRAVERSE, OPT_NO_TRAVERSE]), + .overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE]), ) .arg( - Arg::with_name(OPT_NO_TRAVERSE) - .short(OPT_NO_TRAVERSE) + Arg::with_name(options::traverse::NO_TRAVERSE) + .short(options::traverse::NO_TRAVERSE) .help("do not traverse any symbolic links (default)") - .overrides_with_all(&[OPT_TRAVERSE, OPT_TRAVERSE_EVERY]), + .overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY]), ) .arg( - Arg::with_name(OPT_VERBOSE) - .long(OPT_VERBOSE) + Arg::with_name(options::verbosity::VERBOSE) + .long(options::verbosity::VERBOSE) .help("output a diagnostic for every file processed"), ) .arg( @@ -166,23 +176,23 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); - let preserve_root = matches.is_present(OPT_PRESERVE_ROOT); + let preserve_root = matches.is_present(options::preserve_root::PRESERVE); - let mut derefer = if matches.is_present(OPT_NO_DEREFERENCE) { + let mut derefer = if matches.is_present(options::dereference::NO_DEREFERENCE) { 1 } else { 0 }; - let mut bit_flag = if matches.is_present(OPT_TRAVERSE) { + let mut bit_flag = if matches.is_present(options::traverse::TRAVERSE) { FTS_COMFOLLOW | FTS_PHYSICAL - } else if matches.is_present(OPT_TRAVERSE_EVERY) { + } else if matches.is_present(options::traverse::EVERY) { FTS_LOGICAL } else { FTS_PHYSICAL }; - let recursive = matches.is_present(OPT_RECURSIVE); + let recursive = matches.is_present(options::RECURSIVE); if recursive { if bit_flag == FTS_PHYSICAL { if derefer == 1 { @@ -195,17 +205,19 @@ pub fn uumain(args: impl uucore::Args) -> i32 { bit_flag = FTS_PHYSICAL; } - let verbosity = if matches.is_present(OPT_CHANGES) { + let verbosity = if matches.is_present(options::verbosity::CHANGES) { Verbosity::Changes - } else if matches.is_present(OPT_SILENT) || matches.is_present(OPT_QUIET) { + } else if matches.is_present(options::verbosity::SILENT) + || matches.is_present(options::verbosity::QUIET) + { Verbosity::Silent - } else if matches.is_present(OPT_VERBOSE) { + } else if matches.is_present(options::verbosity::VERBOSE) { Verbosity::Verbose } else { Verbosity::Normal }; - let filter = if let Some(spec) = matches.value_of(OPT_FROM) { + let filter = if let Some(spec) = matches.value_of(options::FROM) { match parse_spec(&spec) { Ok((Some(uid), None)) => IfFrom::User(uid), Ok((None, Some(gid))) => IfFrom::Group(gid), @@ -222,7 +234,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let dest_uid: Option; let dest_gid: Option; - if let Some(file) = matches.value_of(OPT_REFERENCE) { + if let Some(file) = matches.value_of(options::REFERENCE) { match fs::metadata(&file) { Ok(meta) => { dest_gid = Some(meta.gid()); diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index 774a18f2a..7ad2f0908 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chroot" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "chroot ~ (uutils) run COMMAND under a new root directory" @@ -16,7 +16,7 @@ path = "src/chroot.rs" [dependencies] getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 773207363..ab654abf8 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -164,7 +164,7 @@ fn set_main_group(group: &str) { } } -#[cfg(any(target_os = "macos", target_os = "freebsd"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd"))] fn set_groups(groups: Vec) -> libc::c_int { unsafe { setgroups(groups.len() as libc::c_int, groups.as_ptr()) } } diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index 3a3cd6b14..ef3ec8b46 100644 --- a/src/uu/cksum/Cargo.toml +++ b/src/uu/cksum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cksum" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "cksum ~ (uutils) display CRC and size of input" @@ -16,7 +16,7 @@ path = "src/cksum.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index a596fa6b1..ddfbb6a47 100644 --- a/src/uu/comm/Cargo.toml +++ b/src/uu/comm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_comm" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "comm ~ (uutils) compare sorted inputs" @@ -17,7 +17,7 @@ path = "src/comm.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 4f0c3dccb..a0253433f 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cp" -version = "0.0.3" +version = "0.0.4" authors = [ "Jordy Dickinson ", "Joshua S. Miller ", @@ -23,7 +23,7 @@ clap = "2.33" filetime = "0.2" libc = "0.2.85" quick-error = "1.2.3" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index d18edbc10..0922af241 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -207,6 +207,7 @@ pub struct Options { one_file_system: bool, overwrite: OverwriteMode, parents: bool, + strip_trailing_slashes: bool, reflink: bool, reflink_mode: ReflinkMode, preserve_attributes: Vec, @@ -248,6 +249,7 @@ static OPT_NO_DEREFERENCE_PRESERVE_LINKS: &str = "no-dereference-preserve-linkgs static OPT_NO_PRESERVE: &str = "no-preserve"; static OPT_NO_TARGET_DIRECTORY: &str = "no-target-directory"; static OPT_ONE_FILE_SYSTEM: &str = "one-file-system"; +static OPT_PARENT: &str = "parent"; static OPT_PARENTS: &str = "parents"; static OPT_PATHS: &str = "paths"; static OPT_PRESERVE: &str = "preserve"; @@ -333,6 +335,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .arg(Arg::with_name(OPT_RECURSIVE_ALIAS) .short("R") .help("same as -r")) + .arg(Arg::with_name(OPT_STRIP_TRAILING_SLASHES) + .long(OPT_STRIP_TRAILING_SLASHES) + .help("remove any trailing slashes from each SOURCE argument")) .arg(Arg::with_name(OPT_VERBOSE) .short("v") .long(OPT_VERBOSE) @@ -403,6 +408,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .value_name("ATTR_LIST") .conflicts_with_all(&[OPT_PRESERVE_DEFAULT_ATTRIBUTES, OPT_PRESERVE, OPT_ARCHIVE]) .help("don't preserve the specified attributes")) + .arg(Arg::with_name(OPT_PARENTS) + .long(OPT_PARENTS) + .alias(OPT_PARENT) + .help("use full source file name under DIRECTORY")) .arg(Arg::with_name(OPT_NO_DEREFERENCE) .short("-P") .long(OPT_NO_DEREFERENCE) @@ -428,17 +437,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .long(OPT_COPY_CONTENTS) .conflicts_with(OPT_ATTRIBUTES_ONLY) .help("NotImplemented: copy contents of special files when recursive")) - .arg(Arg::with_name(OPT_PARENTS) - .long(OPT_PARENTS) - .help("NotImplemented: use full source file name under DIRECTORY")) .arg(Arg::with_name(OPT_SPARSE) .long(OPT_SPARSE) .takes_value(true) .value_name("WHEN") .help("NotImplemented: control creation of sparse files. See below")) - .arg(Arg::with_name(OPT_STRIP_TRAILING_SLASHES) - .long(OPT_STRIP_TRAILING_SLASHES) - .help("NotImplemented: remove any trailing slashes from each SOURCE argument")) .arg(Arg::with_name(OPT_ONE_FILE_SYSTEM) .short("x") .long(OPT_ONE_FILE_SYSTEM) @@ -559,9 +562,7 @@ impl Options { fn from_matches(matches: &ArgMatches) -> CopyResult { let not_implemented_opts = vec![ OPT_COPY_CONTENTS, - OPT_PARENTS, OPT_SPARSE, - OPT_STRIP_TRAILING_SLASHES, OPT_ONE_FILE_SYSTEM, OPT_CONTEXT, #[cfg(windows)] @@ -629,6 +630,7 @@ impl Options { backup_suffix: matches.value_of(OPT_SUFFIX).unwrap().to_string(), update: matches.is_present(OPT_UPDATE), verbose: matches.is_present(OPT_VERBOSE), + strip_trailing_slashes: matches.is_present(OPT_STRIP_TRAILING_SLASHES), reflink: matches.is_present(OPT_REFLINK), reflink_mode: { if let Some(reflink) = matches.value_of(OPT_REFLINK) { @@ -686,7 +688,7 @@ fn parse_path_args(path_args: &[String], options: &Options) -> CopyResult<(Vec { // All path args are sources, and the target dir was // specified separately @@ -700,6 +702,12 @@ fn parse_path_args(path_args: &[String], options: &Options) -> CopyResult<(Vec { - let root = source_path.parent().unwrap_or(source_path); + let root = if options.parents { + Path::new("") + } else { + source_path.parent().unwrap_or(source_path) + }; localize_to_target(root, source_path, target)? } TargetType::File => target.to_path_buf(), @@ -938,7 +954,7 @@ fn copy_directory(root: &Path, target: &Target, options: &Options) -> CopyResult Some(parent) => { #[cfg(windows)] { - // On Windows, some pathes are starting with \\? + // On Windows, some paths are starting with \\? // but not always, so, make sure that we are consistent for strip_prefix // See https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file for more info let parent_can = adjust_canonicalization(parent); @@ -1231,15 +1247,17 @@ fn copy_helper(source: &Path, dest: &Path, options: &Options) -> CopyResult<()> dest.into() }; symlink_file(&link, &dest, &*context_for(&link, &dest))?; + } else if source.to_string_lossy() == "/dev/null" { + /* workaround a limitation of fs::copy + * https://github.com/rust-lang/rust/issues/79390 + */ + File::create(dest)?; } else { - if source.to_string_lossy() == "/dev/null" { - /* workaround a limitation of fs::copy - * https://github.com/rust-lang/rust/issues/79390 - */ - File::create(dest)?; - } else { - fs::copy(source, dest).context(&*context_for(source, dest))?; + if options.parents { + let parent = dest.parent().unwrap_or(dest); + fs::create_dir_all(parent)?; } + fs::copy(source, dest).context(&*context_for(source, dest))?; } Ok(()) diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index 540e508c7..68c6e2322 100644 --- a/src/uu/csplit/Cargo.toml +++ b/src/uu/csplit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_csplit" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "csplit ~ (uutils) Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output" @@ -19,7 +19,7 @@ getopts = "0.2.17" thiserror = "1.0" regex = "1.0.0" glob = "0.2.11" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 41149a343..7eb287522 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -344,7 +344,7 @@ impl<'a> SplitWriter<'a> { /// /// In addition to errors reading/writing from/to a file, the following errors may be returned: /// - if no line matched, an [`::CsplitError::MatchNotFound`]. - /// - if there are not enough lines to accomodate the offset, an + /// - if there are not enough lines to accommodate the offset, an /// [`::CsplitError::LineOutOfRange`]. fn do_to_match( &mut self, @@ -471,14 +471,14 @@ where } } - /// Rewind the iteration by outputing the buffer's content. + /// Rewind the iteration by outputting the buffer's content. fn rewind_buffer(&mut self) { self.rewind = true; } /// Shrink the buffer so that its length is equal to the set size, returning an iterator for /// the elements that were too much. - fn shrink_buffer_to_size<'a>(&'a mut self) -> impl Iterator + 'a { + fn shrink_buffer_to_size(&mut self) -> impl Iterator + '_ { let mut shrink_offset = 0; if self.buffer.len() > self.size { shrink_offset = self.buffer.len() - self.size; @@ -489,7 +489,7 @@ where } /// Drain the content of the buffer. - fn drain_buffer<'a>(&'a mut self) -> impl Iterator + 'a { + fn drain_buffer(&mut self) -> impl Iterator + '_ { self.buffer.drain(..).map(|(_, line)| line.unwrap()) } diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index 407c79b41..71f7c3f6a 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cut" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "cut ~ (uutils) display byte/field columns of input lines" @@ -15,7 +15,7 @@ edition = "2018" path = "src/cut.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 33399aba0..95411e3fb 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -14,11 +14,10 @@ use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, Read, Stdout, Write}; use std::path::Path; -use self::ranges::Range; use self::searcher::Searcher; +use uucore::ranges::Range; mod buffer; -mod ranges; mod searcher; static SYNTAX: &str = @@ -125,7 +124,7 @@ enum Mode { fn list_to_ranges(list: &str, complement: bool) -> Result, String> { if complement { - Range::from_list(list).map(|r| ranges::complement(&r)) + Range::from_list(list).map(|r| uucore::ranges::complement(&r)) } else { Range::from_list(list) } diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index d2e703991..4e3227f02 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_date" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "date ~ (uutils) display or set the current time" @@ -17,7 +17,7 @@ path = "src/date.rs" [dependencies] chrono = "0.4.4" clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 4977f84d3..24fce763b 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_df" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "df ~ (uutils) display file system information" @@ -18,7 +18,7 @@ path = "src/df.rs" clap = "2.33" libc = "0.2" number_prefix = "0.4" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "windows")'.dependencies] diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index ed2865728..57caf7970 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -32,15 +32,15 @@ use std::ffi::CString; #[cfg(unix)] use std::mem; -#[cfg(any(target_os = "macos", target_os = "freebsd"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd"))] use libc::c_int; -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] use libc::statfs; -#[cfg(any(target_os = "macos", target_os = "freebsd"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd"))] use std::ffi::CStr; -#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "windows"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "windows"))] use std::ptr; -#[cfg(any(target_os = "macos", target_os = "freebsd"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd"))] use std::slice; #[cfg(target_os = "freebsd")] @@ -137,7 +137,7 @@ struct MountInfo { #[cfg(all( target_os = "freebsd", - not(all(target_os = "macos", target_arch = "x86_64")) + not(all(target_vendor = "apple", target_arch = "x86_64")) ))] #[repr(C)] #[derive(Copy, Clone)] @@ -209,20 +209,20 @@ fn get_usage() -> String { format!("{0} [OPTION]... [FILE]...", executable!()) } -#[cfg(any(target_os = "freebsd", target_os = "macos"))] +#[cfg(any(target_os = "freebsd", target_vendor = "apple"))] extern "C" { - #[cfg(all(target_os = "macos", target_arch = "x86_64"))] + #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] #[link_name = "getmntinfo$INODE64"] fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int; #[cfg(any( all(target_os = "freebsd"), - all(target_os = "macos", target_arch = "aarch64") + all(target_vendor = "apple", target_arch = "aarch64") ))] fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int; } -#[cfg(any(target_os = "freebsd", target_os = "macos"))] +#[cfg(any(target_os = "freebsd", target_vendor = "apple"))] impl From for MountInfo { fn from(statfs: statfs) -> Self { let mut info = MountInfo { @@ -585,7 +585,7 @@ fn read_fs_list() -> Vec { }) .collect::>() } - #[cfg(any(target_os = "freebsd", target_os = "macos"))] + #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] { let mut mptr: *mut statfs = ptr::null_mut(); let len = unsafe { getmntinfo(&mut mptr, 1 as c_int) }; diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 7f0b83570..667fc3b70 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dircolors" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "dircolors ~ (uutils) display commands to set LS_COLORS" @@ -16,7 +16,7 @@ path = "src/dircolors.rs" [dependencies] glob = "0.3.0" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index 539c78924..9c565a3e6 100644 --- a/src/uu/dirname/Cargo.toml +++ b/src/uu/dirname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dirname" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "dirname ~ (uutils) display parent directory of PATHNAME" @@ -16,7 +16,7 @@ path = "src/dirname.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index beabb5794..912eef17e 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_du" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "du ~ (uutils) display disk usage" @@ -16,7 +16,7 @@ path = "src/du.rs" [dependencies] time = "0.1.40" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index 0aa661860..a8742b68f 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_echo" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "echo ~ (uutils) display TEXT" @@ -15,7 +15,7 @@ edition = "2018" path = "src/echo.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index 6b3b5440d..864ecd1b2 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_env" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND" @@ -18,7 +18,7 @@ path = "src/env.rs" clap = "2.33" libc = "0.2.42" rust-ini = "0.13.0" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index 83acbdef4..b5c0343e7 100644 --- a/src/uu/expand/Cargo.toml +++ b/src/uu/expand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expand" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "expand ~ (uutils) convert input tabs to spaces" @@ -15,9 +15,9 @@ edition = "2018" path = "src/expand.rs" [dependencies] -getopts = "0.2.18" +clap = "2.33" unicode-width = "0.1.5" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 353c3e6bc..67d24086c 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -12,19 +12,32 @@ #[macro_use] extern crate uucore; +use clap::{App, Arg, ArgMatches}; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write}; use std::iter::repeat; use std::str::from_utf8; use unicode_width::UnicodeWidthChar; -static SYNTAX: &str = "[OPTION]... [FILE]..."; -static SUMMARY: &str = "Convert tabs in each FILE to spaces, writing to standard output. +static VERSION: &str = env!("CARGO_PKG_VERSION"); +static ABOUT: &str = "Convert tabs in each FILE to spaces, writing to standard output. With no FILE, or when FILE is -, read standard input."; + +pub mod options { + pub static TABS: &str = "tabs"; + pub static INITIAL: &str = "initial"; + pub static NO_UTF8: &str = "no-utf8"; + pub static FILES: &str = "FILES"; +} + static LONG_HELP: &str = ""; static DEFAULT_TABSTOP: usize = 8; +fn get_usage() -> String { + format!("{0} [OPTION]... [FILE]...", executable!()) +} + fn tabstops_parse(s: String) -> Vec { let words = s.split(','); @@ -58,14 +71,14 @@ struct Options { } impl Options { - fn new(matches: getopts::Matches) -> Options { - let tabstops = match matches.opt_str("t") { + fn new(matches: &ArgMatches) -> Options { + let tabstops = match matches.value_of(options::TABS) { + Some(s) => tabstops_parse(s.to_string()), None => vec![DEFAULT_TABSTOP], - Some(s) => tabstops_parse(s), }; - let iflag = matches.opt_present("i"); - let uflag = !matches.opt_present("U"); + let iflag = matches.is_present(options::INITIAL); + let uflag = !matches.is_present(options::NO_UTF8); // avoid allocations when dumping out long sequences of spaces // by precomputing the longest string of spaces we will ever need @@ -80,10 +93,9 @@ impl Options { .unwrap(); // length of tabstops is guaranteed >= 1 let tspaces = repeat(' ').take(nspaces).collect(); - let files = if matches.free.is_empty() { - vec!["-".to_owned()] - } else { - matches.free + let files: Vec = match matches.values_of(options::FILES) { + Some(s) => s.map(|v| v.to_string()).collect(), + None => vec!["-".to_owned()], }; Options { @@ -97,31 +109,40 @@ impl Options { } pub fn uumain(args: impl uucore::Args) -> i32 { - let args = args.collect_str(); - - let matches = app!(SYNTAX, SUMMARY, LONG_HELP) - .optflag("i", "initial", "do not convert tabs after non blanks") - .optopt( - "t", - "tabs", - "have tabs NUMBER characters apart, not 8", - "NUMBER", + let usage = get_usage(); + let matches = App::new(executable!()) + .version(VERSION) + .about(ABOUT) + .usage(&usage[..]) + .after_help(LONG_HELP) + .arg( + Arg::with_name(options::INITIAL) + .long(options::INITIAL) + .short("i") + .help("do not convert tabs after non blanks"), ) - .optopt( - "t", - "tabs", - "use comma separated list of explicit tab positions", - "LIST", + .arg( + Arg::with_name(options::TABS) + .long(options::TABS) + .short("t") + .value_name("N, LIST") + .takes_value(true) + .help("have tabs N characters apart, not 8 or use comma separated list of explicit tab positions"), ) - .optflag( - "U", - "no-utf8", - "interpret input file as 8-bit ASCII rather than UTF-8", + .arg( + Arg::with_name(options::NO_UTF8) + .long(options::NO_UTF8) + .short("U") + .help("interpret input file as 8-bit ASCII rather than UTF-8"), + ).arg( + Arg::with_name(options::FILES) + .multiple(true) + .hidden(true) + .takes_value(true) ) - .parse(args); - - expand(Options::new(matches)); + .get_matches_from(args); + expand(Options::new(&matches)); 0 } diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index f3ff65bb2..1246ff873 100644 --- a/src/uu/expr/Cargo.toml +++ b/src/uu/expr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expr" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "expr ~ (uutils) display the value of EXPRESSION" @@ -17,7 +17,7 @@ path = "src/expr.rs" [dependencies] libc = "0.2.42" onig = "~4.3.2" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/factor/Cargo.toml b/src/uu/factor/Cargo.toml index 9724d6fb0..d1160c493 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_factor" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "factor ~ (uutils) display the prime factors of each NUMBER" @@ -19,7 +19,7 @@ num-traits = "0.2.13" # used in src/numerics.rs, which is included by build.rs num-traits = "0.2.13" # Needs at least version 0.2.13 for "OverflowingAdd" rand = { version="0.7", features=["small_rng"] } smallvec = { version="0.6.14, < 1.0" } -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [dev-dependencies] diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index 7beb6a043..2715bad71 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -225,20 +225,19 @@ pub fn factor(num: u64) -> Factors { #[cfg(test)] mod tests { - use super::{factor, Factors}; + use super::{factor, Decomposition, Exponent, Factors}; use quickcheck::quickcheck; + use smallvec::smallvec; + use std::cell::RefCell; #[test] - fn factor_correctly_recombines_prior_test_failures() { - let prior_failures = [ - // * integers with duplicate factors (ie, N.pow(M)) - 4566769_u64, // == 2137.pow(2) - 2044854919485649_u64, - 18446739546814299361_u64, - 18446738440860217487_u64, - 18446736729316206481_u64, - ]; - assert!(prior_failures.iter().all(|i| factor(*i).product() == *i)); + fn factor_2044854919485649() { + let f = Factors(RefCell::new(Decomposition(smallvec![ + (503, 1), + (2423, 1), + (40961, 2) + ]))); + assert_eq!(factor(f.product()), f); } #[test] @@ -248,15 +247,6 @@ mod tests { .all(|i| factor(i).product() == i)); } - #[test] - fn factor_recombines_small_squares() { - // factor(18446736729316206481) == 4294966441 ** 2 ; causes debug_assert fault for repeated decomposition factor in add() - // ToDO: explain/combine with factor_18446736729316206481 and factor_18446739546814299361 tests - assert!((1..10_000) - .map(|i| (2 * i + 1) * (2 * i + 1)) - .all(|i| factor(i).product() == i)); - } - #[test] fn factor_recombines_overflowing() { assert!((0..250) @@ -282,9 +272,15 @@ mod tests { i == 0 || factor(i).product() == i } - fn recombines_factors(f: Factors) -> bool { + fn recombines_factors(f: Factors) -> () { assert_eq!(factor(f.product()), f); - true + } + + fn exponentiate_factors(f: Factors, e: Exponent) -> () { + if e == 0 { return; } + if let Some(fe) = f.product().checked_pow(e.into()) { + assert_eq!(factor(fe), f ^ e); + } } } } @@ -319,3 +315,19 @@ impl quickcheck::Arbitrary for Factors { } } } + +#[cfg(test)] +impl std::ops::BitXor for Factors { + type Output = Self; + + fn bitxor(self, rhs: Exponent) -> Factors { + debug_assert_ne!(rhs, 0); + let mut r = Factors::one(); + for (p, e) in self.0.borrow().0.iter() { + r.add(*p, rhs * e); + } + + debug_assert_eq!(r.product(), self.product().pow(rhs.into())); + return r; + } +} diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index 6c6c64b53..413cbc990 100644 --- a/src/uu/false/Cargo.toml +++ b/src/uu/false/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_false" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "false ~ (uutils) do nothing and fail" @@ -15,7 +15,7 @@ edition = "2018" path = "src/false.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index dc3f7fba5..e150b2962 100644 --- a/src/uu/fmt/Cargo.toml +++ b/src/uu/fmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fmt" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "fmt ~ (uutils) reformat each paragraph of input" @@ -18,7 +18,7 @@ path = "src/fmt.rs" clap = "2.33" libc = "0.2.42" unicode-width = "0.1.5" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index 8299e58b5..23dadc8eb 100644 --- a/src/uu/fold/Cargo.toml +++ b/src/uu/fold/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fold" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "fold ~ (uutils) wrap each line of input" @@ -15,7 +15,7 @@ edition = "2018" path = "src/fold.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index 178f305c1..455e2d224 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_groups" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "groups ~ (uutils) display group memberships for USERNAME" @@ -15,7 +15,7 @@ edition = "2018" path = "src/groups.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } clap = "2.33" diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index 0e120e13a..c9bb4da9f 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hashsum" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "hashsum ~ (uutils) display or check input digests" @@ -26,7 +26,7 @@ sha1 = "0.6.0" sha2 = "0.6.0" sha3 = "0.6.0" blake2-rfc = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index f8b03b15b..adcce2726 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_head" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "head ~ (uutils) display the first lines of input" @@ -16,7 +16,7 @@ path = "src/head.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 56d7e8452..ae5807c22 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -29,6 +29,7 @@ enum FilterMode { struct Settings { mode: FilterMode, verbose: bool, + zero_terminated: bool, } impl Default for Settings { @@ -36,6 +37,7 @@ impl Default for Settings { Settings { mode: FilterMode::Lines(10), verbose: false, + zero_terminated: false, } } } @@ -69,6 +71,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { ) .optflag("q", "quiet", "never print headers giving file names") .optflag("v", "verbose", "always print headers giving file names") + .optflag("z", "zero-terminated", "line delimiter is NUL, not newline") .optflag("h", "help", "display this help and exit") .optflag("V", "version", "output version information and exit") .parse(new_args); @@ -113,6 +116,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let quiet = matches.opt_present("q"); let verbose = matches.opt_present("v"); + settings.zero_terminated = matches.opt_present("z"); let files = matches.free; // GNU implementation allows multiple declarations of "-q" and "-v" with the @@ -203,8 +207,14 @@ fn head(reader: &mut BufReader, settings: &Settings) -> bool { } } FilterMode::Lines(count) => { - for line in reader.lines().take(count) { - println!("{}", line.unwrap()); + if settings.zero_terminated { + for line in reader.split(0).take(count) { + print!("{}\0", String::from_utf8(line.unwrap()).unwrap()) + } + } else { + for line in reader.lines().take(count) { + println!("{}", line.unwrap()); + } } } FilterMode::NLines(count) => { diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index 75686e93a..b3870652e 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostid" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "hostid ~ (uutils) display the numeric identifier of the current host" @@ -16,7 +16,7 @@ path = "src/hostid.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index 34af5600c..75b9b5f9a 100644 --- a/src/uu/hostname/Cargo.toml +++ b/src/uu/hostname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostname" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "hostname ~ (uutils) display or set the host name of the current host" @@ -18,7 +18,7 @@ path = "src/hostname.rs" clap = "2.33" libc = "0.2.42" hostname = { version = "0.3", features = ["set"] } -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["wide"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["wide"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } winapi = { version="0.3", features=["sysinfoapi", "winsock2"] } diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index 0643816db..46e5cb578 100644 --- a/src/uu/id/Cargo.toml +++ b/src/uu/id/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_id" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "id ~ (uutils) display user and group information for USER" @@ -16,7 +16,7 @@ path = "src/id.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "process"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "process"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index f07a850fa..4536622c7 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -291,7 +291,7 @@ fn pretty(possible_pw: Option) { } } -#[cfg(any(target_os = "macos", target_os = "freebsd"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd"))] fn pline(possible_uid: Option) { let uid = possible_uid.unwrap_or_else(getuid); let pw = Passwd::locate(uid).unwrap(); diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index ebea997a0..9841ac64a 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_install" -version = "0.0.3" +version = "0.0.4" authors = [ "Ben Eills ", "uutils developers", @@ -19,8 +19,9 @@ path = "src/install.rs" [dependencies] clap = "2.33" +filetime = "0.2" libc = ">= 0.2" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["mode", "perms", "entries"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["mode", "perms", "entries"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [dev-dependencies] diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index b41b16ef6..9d1acdc7e 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -13,6 +13,7 @@ mod mode; extern crate uucore; use clap::{App, Arg, ArgMatches}; +use filetime::{set_file_times, FileTime}; use uucore::entries::{grp2gid, usr2uid}; use uucore::perms::{wrap_chgrp, wrap_chown, Verbosity}; @@ -32,6 +33,7 @@ pub struct Behavior { owner: String, group: String, verbose: bool, + preserve_timestamps: bool, } #[derive(Clone, Eq, PartialEq)] @@ -154,11 +156,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .takes_value(true) ) .arg( - // TODO implement flag Arg::with_name(OPT_PRESERVE_TIMESTAMPS) .short("p") .long(OPT_PRESERVE_TIMESTAMPS) - .help("(unimplemented) apply access/modification times of SOURCE files to corresponding destination files") + .help("apply access/modification times of SOURCE files to corresponding destination files") ) .arg( // TODO implement flag @@ -265,8 +266,6 @@ fn check_unimplemented<'a>(matches: &ArgMatches) -> Result<(), &'a str> { Err("--compare, -C") } else if matches.is_present(OPT_CREATED) { Err("-D") - } else if matches.is_present(OPT_PRESERVE_TIMESTAMPS) { - Err("--preserve-timestamps, -p") } else if matches.is_present(OPT_STRIP) { Err("--strip, -s") } else if matches.is_present(OPT_STRIP_PROGRAM) { @@ -338,6 +337,7 @@ fn behavior(matches: &ArgMatches) -> Result { owner: matches.value_of(OPT_OWNER).unwrap_or("").to_string(), group: matches.value_of(OPT_GROUP).unwrap_or("").to_string(), verbose: matches.is_present(OPT_VERBOSE), + preserve_timestamps: matches.is_present(OPT_PRESERVE_TIMESTAMPS), }) } @@ -555,6 +555,21 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> { } } + if b.preserve_timestamps { + let meta = match fs::metadata(from) { + Ok(meta) => meta, + Err(f) => crash!(1, "{}", f.to_string()), + }; + + let modified_time = FileTime::from_last_modification_time(&meta); + let accessed_time = FileTime::from_last_access_time(&meta); + + match set_file_times(to.as_path(), accessed_time, modified_time) { + Ok(_) => {} + Err(e) => show_info!("{}", e), + } + } + if b.verbose { show_info!("'{}' -> '{}'", from.display(), to.display()); } diff --git a/src/uu/join/Cargo.toml b/src/uu/join/Cargo.toml index bfe81c098..d02703a62 100644 --- a/src/uu/join/Cargo.toml +++ b/src/uu/join/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_join" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "join ~ (uutils) merge lines from inputs with matching join fields" @@ -16,7 +16,7 @@ path = "src/join.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index 8bb70a164..dd69cd35d 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_kill" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "kill ~ (uutils) send a signal to a process" @@ -16,7 +16,7 @@ path = "src/kill.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["signals"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["signals"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index fce502a29..aaa183981 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_link" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "link ~ (uutils) create a hard (file system) link to FILE" @@ -16,7 +16,7 @@ path = "src/link.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index c2e7f3cf7..2b97f025a 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ln" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "ln ~ (uutils) create a (file system) link to TARGET" @@ -17,7 +17,7 @@ path = "src/ln.rs" [dependencies] clap = "2.33" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index e06468367..ab07a2b08 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -207,7 +207,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let paths: Vec = matches .values_of(ARG_FILES) .unwrap() - .map(|path| PathBuf::from(path)) + .map(PathBuf::from) .collect(); let overwrite_mode = if matches.is_present(OPT_FORCE) { @@ -316,9 +316,8 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &PathBuf, settings: &Setting // We need to clean the target if is_symlink(target_dir) { if target_dir.is_file() { - match fs::remove_file(target_dir) { - Err(e) => show_error!("Could not update {}: {}", target_dir.display(), e), - _ => (), + if let Err(e) = fs::remove_file(target_dir) { + show_error!("Could not update {}: {}", target_dir.display(), e) }; } if target_dir.is_dir() { @@ -423,10 +422,8 @@ fn link(src: &PathBuf, dst: &PathBuf, settings: &Settings) -> Result<()> { } } - if settings.no_dereference && settings.force { - if dst.exists() { - fs::remove_file(dst)?; - } + if settings.no_dereference && settings.force && dst.exists() { + fs::remove_file(dst)?; } if settings.symbolic { diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 310dc1207..d58576c77 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_logname" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "logname ~ (uutils) display the login name of the current user" @@ -16,7 +16,7 @@ path = "src/logname.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index f65f9aa2e..10d7cc2da 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ls" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "ls ~ (uutils) display directory contents" @@ -22,7 +22,7 @@ term_grid = "0.1.5" termsize = "0.1.6" time = "0.1.40" unicode-width = "0.1.5" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/mkdir/Cargo.toml b/src/uu/mkdir/Cargo.toml index 494e221e1..9cedb5c03 100644 --- a/src/uu/mkdir/Cargo.toml +++ b/src/uu/mkdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkdir" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "mkdir ~ (uutils) create DIRECTORY" @@ -17,7 +17,7 @@ path = "src/mkdir.rs" [dependencies] clap = "2.33" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs", "mode"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs", "mode"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index 905cf5bbe..627d4a721 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkfifo" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "mkfifo ~ (uutils) create FIFOs (named pipes)" @@ -17,7 +17,7 @@ path = "src/mkfifo.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index b6d6887b7..426534e75 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mknod" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "mknod ~ (uutils) create special file NAME of TYPE" @@ -18,7 +18,7 @@ path = "src/mknod.rs" [dependencies] getopts = "0.2.18" libc = "^0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["mode"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["mode"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index 4ba45dd92..c48306a40 100644 --- a/src/uu/mktemp/Cargo.toml +++ b/src/uu/mktemp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mktemp" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "mktemp ~ (uutils) create and display a temporary file or directory from TEMPLATE" @@ -18,7 +18,7 @@ path = "src/mktemp.rs" clap = "2.33" rand = "0.5" tempfile = "3.1" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 8969dc51c..194b6625f 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -25,6 +25,7 @@ mod tempdir; static ABOUT: &str = "create a temporary file or directory."; static VERSION: &str = env!("CARGO_PKG_VERSION"); + static DEFAULT_TEMPLATE: &str = "tmp.XXXXXXXXXX"; static OPT_DIRECTORY: &str = "directory"; @@ -119,13 +120,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { // See https://github.com/clap-rs/clap/pull/1587 let tmp = env::temp_dir(); (tmpdir, tmp) + } else if !matches.is_present(OPT_TMPDIR) { + let tmp = env::temp_dir(); + (template, tmp) } else { - if !matches.is_present(OPT_TMPDIR) { - let tmp = env::temp_dir(); - (template, tmp) - } else { - (template, PathBuf::from(tmpdir)) - } + (template, PathBuf::from(tmpdir)) }; let make_dir = matches.is_present(OPT_DIRECTORY); @@ -157,14 +156,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 { crash!(1, "suffix cannot contain any path separators"); } - if matches.is_present(OPT_TMPDIR) { - if PathBuf::from(prefix).is_absolute() { - show_info!( - "invalid template, ‘{}’; with --tmpdir, it may not be absolute", - template - ); - return 1; - } + if matches.is_present(OPT_TMPDIR) && PathBuf::from(prefix).is_absolute() { + show_info!( + "invalid template, ‘{}’; with --tmpdir, it may not be absolute", + template + ); + return 1; }; if matches.is_present(OPT_T) { diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index a54b8b2d6..acd9378b2 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_more" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "more ~ (uutils) input perusal filter" @@ -16,15 +16,15 @@ path = "src/more.rs" [dependencies] getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } +uucore = { version = ">=0.0.7", package = "uucore", path = "../../uucore" } +uucore_procs = { version = ">=0.0.5", package = "uucore_procs", path = "../../uucore_procs" } [target.'cfg(target_os = "redox")'.dependencies] redox_termios = "0.1" redox_syscall = "0.1" [target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] -nix = "0.8.1" +nix = "<=0.13" [[bin]] name = "more" diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index de4e10187..524b0fbc4 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -17,7 +17,7 @@ use std::io::{stdout, Read, Write}; #[cfg(all(unix, not(target_os = "fuchsia")))] extern crate nix; #[cfg(all(unix, not(target_os = "fuchsia")))] -use nix::sys::termios; +use nix::sys::termios::{self, LocalFlags, SetArg}; #[cfg(target_os = "redox")] extern crate redox_termios; @@ -92,10 +92,10 @@ fn help(usage: &str) { fn setup_term() -> termios::Termios { let mut term = termios::tcgetattr(0).unwrap(); // Unset canonical mode, so we get characters immediately - term.c_lflag.remove(termios::ICANON); + term.local_flags.remove(LocalFlags::ICANON); // Disable local echo - term.c_lflag.remove(termios::ECHO); - termios::tcsetattr(0, termios::TCSADRAIN, &term).unwrap(); + term.local_flags.remove(LocalFlags::ECHO); + termios::tcsetattr(0, SetArg::TCSADRAIN, &term).unwrap(); term } @@ -110,8 +110,8 @@ fn setup_term() -> redox_termios::Termios { let mut term = redox_termios::Termios::default(); let fd = syscall::dup(0, b"termios").unwrap(); syscall::read(fd, &mut term).unwrap(); - term.c_lflag &= !redox_termios::ICANON; - term.c_lflag &= !redox_termios::ECHO; + term.local_flags &= !redox_termios::ICANON; + term.local_flags &= !redox_termios::ECHO; syscall::write(fd, &term).unwrap(); let _ = syscall::close(fd); term @@ -119,9 +119,9 @@ fn setup_term() -> redox_termios::Termios { #[cfg(all(unix, not(target_os = "fuchsia")))] fn reset_term(term: &mut termios::Termios) { - term.c_lflag.insert(termios::ICANON); - term.c_lflag.insert(termios::ECHO); - termios::tcsetattr(0, termios::TCSADRAIN, &term).unwrap(); + term.local_flags.insert(LocalFlags::ICANON); + term.local_flags.insert(LocalFlags::ECHO); + termios::tcsetattr(0, SetArg::TCSADRAIN, &term).unwrap(); } #[cfg(any(windows, target_os = "fuchsia"))] @@ -132,8 +132,8 @@ fn reset_term(_: &mut usize) {} fn reset_term(term: &mut redox_termios::Termios) { let fd = syscall::dup(0, b"termios").unwrap(); syscall::read(fd, term).unwrap(); - term.c_lflag |= redox_termios::ICANON; - term.c_lflag |= redox_termios::ECHO; + term.local_flags |= redox_termios::ICANON; + term.local_flags |= redox_termios::ECHO; syscall::write(fd, &term).unwrap(); let _ = syscall::close(fd); } diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index eed89e1f4..1a4f90801 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mv" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "mv ~ (uutils) move (rename) SOURCE to DESTINATION" @@ -17,7 +17,7 @@ path = "src/mv.rs" [dependencies] clap = "2.33" fs_extra = "1.1.0" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 200c0f5df..c851daa5a 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nice" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "nice ~ (uutils) run PROGRAM with modified scheduling priority" @@ -15,9 +15,10 @@ edition = "2018" path = "src/nice.rs" [dependencies] -getopts = "0.2.18" +clap = "2.33" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +nix = { version="<=0.13" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index 1f79ea09b..c1d3345af 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -15,7 +15,7 @@ use std::ffi::CString; use std::io::Error; use std::ptr; -const NAME: &str = "nice"; +use clap::{App, AppSettings, Arg}; const VERSION: &str = env!("CARGO_PKG_VERSION"); // XXX: PRIO_PROCESS is 0 on at least FreeBSD and Linux. Don't know about Mac OS X. @@ -26,64 +26,57 @@ extern "C" { fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; } -pub fn uumain(args: impl uucore::Args) -> i32 { - let args = args.collect_str(); +pub mod options { + pub static ADJUSTMENT: &str = "adjustment"; + pub static COMMAND: &str = "COMMAND"; +} - let mut opts = getopts::Options::new(); - - opts.optopt( - "n", - "adjustment", - "add N to the niceness (default is 10)", - "N", - ); - opts.optflag("h", "help", "display this help and exit"); - opts.optflag("V", "version", "output version information and exit"); - - let matches = match opts.parse(&args[1..]) { - Ok(m) => m, - Err(err) => { - show_error!("{}", err); - return 125; - } - }; - - if matches.opt_present("version") { - println!("{} {}", NAME, VERSION); - return 0; - } - - if matches.opt_present("help") { - let msg = format!( - "{0} {1} - -Usage: +fn get_usage() -> String { + format!( + " {0} [OPTIONS] [COMMAND [ARGS]] Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Niceness values range from at least -20 (most favorable to the process) to 19 (least favorable to the process).", - NAME, VERSION - ); + executable!() + ) +} - print!("{}", opts.usage(&msg)); - return 0; - } +pub fn uumain(args: impl uucore::Args) -> i32 { + let usage = get_usage(); - let mut niceness = unsafe { getpriority(PRIO_PROCESS, 0) }; + let matches = App::new(executable!()) + .setting(AppSettings::TrailingVarArg) + .version(VERSION) + .usage(&usage[..]) + .arg( + Arg::with_name(options::ADJUSTMENT) + .short("n") + .long(options::ADJUSTMENT) + .help("add N to the niceness (default is 10)") + .takes_value(true) + .allow_hyphen_values(true), + ) + .arg(Arg::with_name(options::COMMAND).multiple(true)) + .get_matches_from(args); + + let mut niceness = unsafe { + nix::errno::Errno::clear(); + getpriority(PRIO_PROCESS, 0) + }; if Error::last_os_error().raw_os_error().unwrap() != 0 { - show_error!("{}", Error::last_os_error()); + show_error!("getpriority: {}", Error::last_os_error()); return 125; } - let adjustment = match matches.opt_str("adjustment") { + let adjustment = match matches.value_of(options::ADJUSTMENT) { Some(nstr) => { - if matches.free.is_empty() { + if !matches.is_present(options::COMMAND) { show_error!( - "A command must be given with an adjustment. - Try \"{} --help\" for more information.", - args[0] + "A command must be given with an adjustment.\nTry \"{} --help\" for more information.", + executable!() ); return 125; } @@ -96,7 +89,7 @@ process).", } } None => { - if matches.free.is_empty() { + if !matches.is_present(options::COMMAND) { println!("{}", niceness); return 0; } @@ -105,25 +98,23 @@ process).", }; niceness += adjustment; - unsafe { - setpriority(PRIO_PROCESS, 0, niceness); - } - if Error::last_os_error().raw_os_error().unwrap() != 0 { - show_warning!("{}", Error::last_os_error()); + if unsafe { setpriority(PRIO_PROCESS, 0, niceness) } == -1 { + show_warning!("setpriority: {}", Error::last_os_error()); } let cstrs: Vec = matches - .free - .iter() + .values_of(options::COMMAND) + .unwrap() .map(|x| CString::new(x.as_bytes()).unwrap()) .collect(); + let mut args: Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); args.push(ptr::null::()); unsafe { execvp(args[0], args.as_mut_ptr()); } - show_error!("{}", Error::last_os_error()); + show_error!("execvp: {}", Error::last_os_error()); if Error::last_os_error().raw_os_error().unwrap() as c_int == libc::ENOENT { 127 } else { diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index 80733f424..d5cddbde2 100644 --- a/src/uu/nl/Cargo.toml +++ b/src/uu/nl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nl" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "nl ~ (uutils) display input with added line numbers" @@ -21,7 +21,7 @@ libc = "0.2.42" memchr = "2.2.0" regex = "1.0.1" regex-syntax = "0.6.7" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs index e34cfd2ae..9b98129f1 100644 --- a/src/uu/nl/src/helper.rs +++ b/src/uu/nl/src/helper.rs @@ -11,7 +11,9 @@ fn parse_style(chars: &[char]) -> Result { } else if chars.len() > 1 && chars[0] == 'p' { let s: String = chars[1..].iter().cloned().collect(); match regex::Regex::new(&s) { - Ok(re) => Ok(crate::NumberingStyle::NumberForRegularExpression(re)), + Ok(re) => Ok(crate::NumberingStyle::NumberForRegularExpression(Box::new( + re, + ))), Err(_) => Err(String::from("Illegal regular expression")), } } else { diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 105bb196b..47b6c3ae9 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -55,7 +55,7 @@ enum NumberingStyle { NumberForAll, NumberForNonEmpty, NumberForNone, - NumberForRegularExpression(regex::Regex), + NumberForRegularExpression(Box), } // NumberFormat specifies how line numbers are output within their allocated diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index 349cde7aa..0c5709a65 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nohup" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "nohup ~ (uutils) run COMMAND, ignoring hangup signals" @@ -17,7 +17,7 @@ path = "src/nohup.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 67e281e38..5fce208da 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -23,7 +23,7 @@ use uucore::fs::{is_stderr_interactive, is_stdin_interactive, is_stdout_interact static NAME: &str = "nohup"; static VERSION: &str = env!("CARGO_PKG_VERSION"); -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] extern "C" { fn _vprocmgr_detach_from_console(flags: u32) -> *const libc::c_int; } diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index 7194f99e2..98f9a4afa 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nproc" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "nproc ~ (uutils) display the number of processing units available" @@ -18,7 +18,7 @@ path = "src/nproc.rs" libc = "0.2.42" num_cpus = "1.10" clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 4eb538618..285cf764f 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -15,7 +15,7 @@ use std::env; #[cfg(target_os = "linux")] pub const _SC_NPROCESSORS_CONF: libc::c_int = 83; -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] pub const _SC_NPROCESSORS_CONF: libc::c_int = libc::_SC_NPROCESSORS_CONF; #[cfg(target_os = "freebsd")] pub const _SC_NPROCESSORS_CONF: libc::c_int = 57; @@ -89,7 +89,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { #[cfg(any( target_os = "linux", - target_os = "macos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd" ))] @@ -109,7 +109,7 @@ fn num_cpus_all() -> usize { // Other platforms (e.g., windows), num_cpus::get() directly. #[cfg(not(any( target_os = "linux", - target_os = "macos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd" )))] diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index 65f3570e9..b8e54656c 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_numfmt" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "numfmt ~ (uutils) reformat NUMBER" @@ -16,7 +16,7 @@ path = "src/numfmt.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/numfmt/src/format.rs b/src/uu/numfmt/src/format.rs new file mode 100644 index 000000000..ebe380569 --- /dev/null +++ b/src/uu/numfmt/src/format.rs @@ -0,0 +1,296 @@ +use crate::options::NumfmtOptions; +use crate::units::{ + DisplayableSuffix, RawSuffix, Result, Suffix, Transform, Unit, IEC_BASES, SI_BASES, +}; + +/// Iterate over a line's fields, where each field is a contiguous sequence of +/// non-whitespace, optionally prefixed with one or more characters of leading +/// whitespace. Fields are returned as tuples of `(prefix, field)`. +/// +/// # Examples: +/// +/// ``` +/// let mut fields = uu_numfmt::format::WhitespaceSplitter { s: Some(" 1234 5") }; +/// +/// assert_eq!(Some((" ", "1234")), fields.next()); +/// assert_eq!(Some((" ", "5")), fields.next()); +/// assert_eq!(None, fields.next()); +/// ``` +/// +/// Delimiters are included in the results; `prefix` will be empty only for +/// the first field of the line (including the case where the input line is +/// empty): +/// +/// ``` +/// let mut fields = uu_numfmt::format::WhitespaceSplitter { s: Some("first second") }; +/// +/// assert_eq!(Some(("", "first")), fields.next()); +/// assert_eq!(Some((" ", "second")), fields.next()); +/// +/// let mut fields = uu_numfmt::format::WhitespaceSplitter { s: Some("") }; +/// +/// assert_eq!(Some(("", "")), fields.next()); +/// ``` +pub struct WhitespaceSplitter<'a> { + pub s: Option<&'a str>, +} + +impl<'a> Iterator for WhitespaceSplitter<'a> { + type Item = (&'a str, &'a str); + + /// Yield the next field in the input string as a tuple `(prefix, field)`. + fn next(&mut self) -> Option { + let haystack = self.s?; + + let (prefix, field) = haystack.split_at( + haystack + .find(|c: char| !c.is_whitespace()) + .unwrap_or_else(|| haystack.len()), + ); + + let (field, rest) = field.split_at( + field + .find(|c: char| c.is_whitespace()) + .unwrap_or_else(|| field.len()), + ); + + self.s = if !rest.is_empty() { Some(rest) } else { None }; + + Some((prefix, field)) + } +} + +fn parse_suffix(s: &str) -> Result<(f64, Option)> { + if s.is_empty() { + return Err("invalid number: ‘’".to_string()); + } + + let with_i = s.ends_with('i'); + let mut iter = s.chars(); + if with_i { + iter.next_back(); + } + let suffix: Option = match iter.next_back() { + Some('K') => Ok(Some((RawSuffix::K, with_i))), + Some('M') => Ok(Some((RawSuffix::M, with_i))), + Some('G') => Ok(Some((RawSuffix::G, with_i))), + Some('T') => Ok(Some((RawSuffix::T, with_i))), + Some('P') => Ok(Some((RawSuffix::P, with_i))), + Some('E') => Ok(Some((RawSuffix::E, with_i))), + Some('Z') => Ok(Some((RawSuffix::Z, with_i))), + Some('Y') => Ok(Some((RawSuffix::Y, with_i))), + Some('0'..='9') => Ok(None), + _ => Err(format!("invalid suffix in input: ‘{}’", s)), + }?; + + let suffix_len = match suffix { + None => 0, + Some((_, false)) => 1, + Some((_, true)) => 2, + }; + + let number = s[..s.len() - suffix_len] + .parse::() + .map_err(|_| format!("invalid number: ‘{}’", s))?; + + Ok((number, suffix)) +} + +fn remove_suffix(i: f64, s: Option, u: &Unit) -> Result { + match (s, u) { + (None, _) => Ok(i), + (Some((raw_suffix, false)), &Unit::Auto) | (Some((raw_suffix, false)), &Unit::Si) => { + match raw_suffix { + RawSuffix::K => Ok(i * 1e3), + RawSuffix::M => Ok(i * 1e6), + RawSuffix::G => Ok(i * 1e9), + RawSuffix::T => Ok(i * 1e12), + RawSuffix::P => Ok(i * 1e15), + RawSuffix::E => Ok(i * 1e18), + RawSuffix::Z => Ok(i * 1e21), + RawSuffix::Y => Ok(i * 1e24), + } + } + (Some((raw_suffix, false)), &Unit::Iec(false)) + | (Some((raw_suffix, true)), &Unit::Auto) + | (Some((raw_suffix, true)), &Unit::Iec(true)) => match raw_suffix { + RawSuffix::K => Ok(i * IEC_BASES[1]), + RawSuffix::M => Ok(i * IEC_BASES[2]), + RawSuffix::G => Ok(i * IEC_BASES[3]), + RawSuffix::T => Ok(i * IEC_BASES[4]), + RawSuffix::P => Ok(i * IEC_BASES[5]), + RawSuffix::E => Ok(i * IEC_BASES[6]), + RawSuffix::Z => Ok(i * IEC_BASES[7]), + RawSuffix::Y => Ok(i * IEC_BASES[8]), + }, + (_, _) => Err("This suffix is unsupported for specified unit".to_owned()), + } +} + +fn transform_from(s: &str, opts: &Transform) -> Result { + let (i, suffix) = parse_suffix(s)?; + + remove_suffix(i, suffix, &opts.unit).map(|n| if n < 0.0 { -n.abs().ceil() } else { n.ceil() }) +} + +/// Divide numerator by denominator, with ceiling. +/// +/// If the result of the division is less than 10.0, truncate the result +/// to the next highest tenth. +/// +/// Otherwise, truncate the result to the next highest whole number. +/// +/// # Examples: +/// +/// ``` +/// use uu_numfmt::format::div_ceil; +/// +/// assert_eq!(div_ceil(1.01, 1.0), 1.1); +/// assert_eq!(div_ceil(999.1, 1000.), 1.0); +/// assert_eq!(div_ceil(1001., 10.), 101.); +/// assert_eq!(div_ceil(9991., 10.), 1000.); +/// assert_eq!(div_ceil(-12.34, 1.0), -13.0); +/// assert_eq!(div_ceil(1000.0, -3.14), -319.0); +/// assert_eq!(div_ceil(-271828.0, -271.0), 1004.0); +/// ``` +pub fn div_ceil(n: f64, d: f64) -> f64 { + let v = n / (d / 10.0); + let (v, sign) = if v < 0.0 { (v.abs(), -1.0) } else { (v, 1.0) }; + + if v < 100.0 { + v.ceil() / 10.0 * sign + } else { + (v / 10.0).ceil() * sign + } +} + +fn consider_suffix(n: f64, u: &Unit) -> Result<(f64, Option)> { + use crate::units::RawSuffix::*; + + let abs_n = n.abs(); + let suffixes = [K, M, G, T, P, E, Z, Y]; + + let (bases, with_i) = match *u { + Unit::Si => (&SI_BASES, false), + Unit::Iec(with_i) => (&IEC_BASES, with_i), + Unit::Auto => return Err("Unit 'auto' isn't supported with --to options".to_owned()), + Unit::None => return Ok((n, None)), + }; + + let i = match abs_n { + _ if abs_n <= bases[1] - 1.0 => return Ok((n, None)), + _ if abs_n < bases[2] => 1, + _ if abs_n < bases[3] => 2, + _ if abs_n < bases[4] => 3, + _ if abs_n < bases[5] => 4, + _ if abs_n < bases[6] => 5, + _ if abs_n < bases[7] => 6, + _ if abs_n < bases[8] => 7, + _ if abs_n < bases[9] => 8, + _ => return Err("Number is too big and unsupported".to_string()), + }; + + let v = div_ceil(n, bases[i]); + + // check if rounding pushed us into the next base + if v.abs() >= bases[1] { + Ok((v / bases[1], Some((suffixes[i], with_i)))) + } else { + Ok((v, Some((suffixes[i - 1], with_i)))) + } +} + +fn transform_to(s: f64, opts: &Transform) -> Result { + let (i2, s) = consider_suffix(s, &opts.unit)?; + Ok(match s { + None => format!("{}", i2), + Some(s) if i2.abs() < 10.0 => format!("{:.1}{}", i2, DisplayableSuffix(s)), + Some(s) => format!("{:.0}{}", i2, DisplayableSuffix(s)), + }) +} + +fn format_string( + source: &str, + options: &NumfmtOptions, + implicit_padding: Option, +) -> Result { + let number = transform_to( + transform_from(source, &options.transform.from)?, + &options.transform.to, + )?; + + Ok(match implicit_padding.unwrap_or(options.padding) { + p if p == 0 => number, + p if p > 0 => format!("{:>padding$}", number, padding = p as usize), + p => format!("{: Result<()> { + let delimiter = options.delimiter.as_ref().unwrap(); + + for (n, field) in (1..).zip(s.split(delimiter)) { + let field_selected = uucore::ranges::contain(&options.fields, n); + + // print delimiter before second and subsequent fields + if n > 1 { + print!("{}", delimiter); + } + + if field_selected { + print!("{}", format_string(&field.trim_start(), options, None)?); + } else { + // print unselected field without conversion + print!("{}", field); + } + } + + println!(); + + Ok(()) +} + +fn format_and_print_whitespace(s: &str, options: &NumfmtOptions) -> Result<()> { + for (n, (prefix, field)) in (1..).zip(WhitespaceSplitter { s: Some(s) }) { + let field_selected = uucore::ranges::contain(&options.fields, n); + + if field_selected { + let empty_prefix = prefix.is_empty(); + + // print delimiter before second and subsequent fields + let prefix = if n > 1 { + print!(" "); + &prefix[1..] + } else { + &prefix + }; + + let implicit_padding = if !empty_prefix && options.padding == 0 { + Some((prefix.len() + field.len()) as isize) + } else { + None + }; + + print!("{}", format_string(&field, options, implicit_padding)?); + } else { + // print unselected field without conversion + print!("{}{}", prefix, field); + } + } + + println!(); + + Ok(()) +} + +/// Format a line of text according to the selected options. +/// +/// Given a line of text `s`, split the line into fields, transform and format +/// any selected numeric fields, and print the result to stdout. Fields not +/// selected for conversion are passed through unmodified. +pub fn format_and_print(s: &str, options: &NumfmtOptions) -> Result<()> { + match &options.delimiter { + Some(_) => format_and_print_delimited(s, options), + None => format_and_print_whitespace(s, options), + } +} diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 4d3b7387a..29c422a89 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -5,13 +5,19 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use std::fmt; -use std::io::BufRead; - #[macro_use] extern crate uucore; -use clap::{App, Arg, ArgMatches}; +use crate::format::format_and_print; +use crate::options::*; +use crate::units::{Result, Transform, Unit}; +use clap::{App, AppSettings, Arg, ArgMatches}; +use std::io::{BufRead, Write}; +use uucore::ranges::Range; + +pub mod format; +mod options; +mod units; static VERSION: &str = env!("CARGO_PKG_VERSION"); static ABOUT: &str = "Convert numbers from/to human-readable strings"; @@ -33,113 +39,43 @@ static LONG_HELP: &str = "UNIT options: iec-i accept optional two-letter suffix: 1Ki = 1024, 1Mi = 1048576, ... -"; -mod options { - pub const FROM: &str = "from"; - pub const FROM_DEFAULT: &str = "none"; - pub const HEADER: &str = "header"; - pub const HEADER_DEFAULT: &str = "1"; - pub const NUMBER: &str = "NUMBER"; - pub const PADDING: &str = "padding"; - pub const TO: &str = "to"; - pub const TO_DEFAULT: &str = "none"; -} +FIELDS supports cut(1) style field ranges: + N N'th field, counted from 1 + N- from N'th field, to end of line + N-M from N'th to M'th field (inclusive) + -M from first to M'th field (inclusive) + - all fields +Multiple fields/ranges can be separated with commas +"; fn get_usage() -> String { format!("{0} [OPTION]... [NUMBER]...", executable!()) } -const IEC_BASES: [f64; 10] = [ - //premature optimization - 1., - 1_024., - 1_048_576., - 1_073_741_824., - 1_099_511_627_776., - 1_125_899_906_842_624., - 1_152_921_504_606_846_976., - 1_180_591_620_717_411_303_424., - 1_208_925_819_614_629_174_706_176., - 1_237_940_039_285_380_274_899_124_224., -]; - -type Result = std::result::Result; - -type WithI = bool; - -enum Unit { - Auto, - Si, - Iec(WithI), - None, -} - -enum RawSuffix { - K, - M, - G, - T, - P, - E, - Z, - Y, -} - -type Suffix = (RawSuffix, WithI); - -struct DisplayableSuffix(Suffix); - -impl fmt::Display for DisplayableSuffix { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let DisplayableSuffix((ref raw_suffix, ref with_i)) = *self; - match raw_suffix { - RawSuffix::K => write!(f, "K"), - RawSuffix::M => write!(f, "M"), - RawSuffix::G => write!(f, "G"), - RawSuffix::T => write!(f, "T"), - RawSuffix::P => write!(f, "P"), - RawSuffix::E => write!(f, "E"), - RawSuffix::Z => write!(f, "Z"), - RawSuffix::Y => write!(f, "Y"), - } - .and_then(|()| match with_i { - true => write!(f, "i"), - false => Ok(()), - }) +fn handle_args<'a>(args: impl Iterator, options: NumfmtOptions) -> Result<()> { + for l in args { + format_and_print(l, &options)?; } + + Ok(()) } -fn parse_suffix(s: &str) -> Result<(f64, Option)> { - let with_i = s.ends_with('i'); - let mut iter = s.chars(); - if with_i { - iter.next_back(); +fn handle_stdin(options: NumfmtOptions) -> Result<()> { + let stdin = std::io::stdin(); + let locked_stdin = stdin.lock(); + + let mut lines = locked_stdin.lines(); + for l in lines.by_ref().take(options.header) { + l.map(|s| println!("{}", s)).map_err(|e| e.to_string())?; } - let suffix: Option = match iter.next_back() { - Some('K') => Ok(Some((RawSuffix::K, with_i))), - Some('M') => Ok(Some((RawSuffix::M, with_i))), - Some('G') => Ok(Some((RawSuffix::G, with_i))), - Some('T') => Ok(Some((RawSuffix::T, with_i))), - Some('P') => Ok(Some((RawSuffix::P, with_i))), - Some('E') => Ok(Some((RawSuffix::E, with_i))), - Some('Z') => Ok(Some((RawSuffix::Z, with_i))), - Some('Y') => Ok(Some((RawSuffix::Y, with_i))), - Some('0'..='9') => Ok(None), - _ => Err(format!("invalid suffix in input: ‘{}’", s)), - }?; - let suffix_len = match suffix { - None => 0, - Some((_, false)) => 1, - Some((_, true)) => 2, - }; + for l in lines { + l.map_err(|e| e.to_string()) + .and_then(|l| format_and_print(&l, &options))?; + } - let number = s[..s.len() - suffix_len] - .parse::() - .map_err(|_| format!("invalid number: ‘{}’", s))?; - - Ok((number, suffix)) + Ok(()) } fn parse_unit(s: &str) -> Result { @@ -153,128 +89,6 @@ fn parse_unit(s: &str) -> Result { } } -struct TransformOptions { - from: Transform, - to: Transform, -} - -struct Transform { - unit: Unit, -} - -struct NumfmtOptions { - transform: TransformOptions, - padding: isize, - header: usize, -} - -fn remove_suffix(i: f64, s: Option, u: &Unit) -> Result { - match (s, u) { - (None, _) => Ok(i), - (Some((raw_suffix, false)), &Unit::Auto) | (Some((raw_suffix, false)), &Unit::Si) => { - match raw_suffix { - RawSuffix::K => Ok(i * 1e3), - RawSuffix::M => Ok(i * 1e6), - RawSuffix::G => Ok(i * 1e9), - RawSuffix::T => Ok(i * 1e12), - RawSuffix::P => Ok(i * 1e15), - RawSuffix::E => Ok(i * 1e18), - RawSuffix::Z => Ok(i * 1e21), - RawSuffix::Y => Ok(i * 1e24), - } - } - (Some((raw_suffix, false)), &Unit::Iec(false)) - | (Some((raw_suffix, true)), &Unit::Auto) - | (Some((raw_suffix, true)), &Unit::Iec(true)) => match raw_suffix { - RawSuffix::K => Ok(i * IEC_BASES[1]), - RawSuffix::M => Ok(i * IEC_BASES[2]), - RawSuffix::G => Ok(i * IEC_BASES[3]), - RawSuffix::T => Ok(i * IEC_BASES[4]), - RawSuffix::P => Ok(i * IEC_BASES[5]), - RawSuffix::E => Ok(i * IEC_BASES[6]), - RawSuffix::Z => Ok(i * IEC_BASES[7]), - RawSuffix::Y => Ok(i * IEC_BASES[8]), - }, - (_, _) => Err("This suffix is unsupported for specified unit".to_owned()), - } -} - -fn transform_from(s: &str, opts: &Transform) -> Result { - let (i, suffix) = parse_suffix(s)?; - remove_suffix(i, suffix, &opts.unit).map(|n| n.round()) -} - -fn consider_suffix(i: f64, u: &Unit) -> Result<(f64, Option)> { - let j = i.abs(); - match *u { - Unit::Si => match j { - _ if j < 1e3 => Ok((i, None)), - _ if j < 1e6 => Ok((i / 1e3, Some((RawSuffix::K, false)))), - _ if j < 1e9 => Ok((i / 1e6, Some((RawSuffix::M, false)))), - _ if j < 1e12 => Ok((i / 1e9, Some((RawSuffix::G, false)))), - _ if j < 1e15 => Ok((i / 1e12, Some((RawSuffix::T, false)))), - _ if j < 1e18 => Ok((i / 1e15, Some((RawSuffix::P, false)))), - _ if j < 1e21 => Ok((i / 1e18, Some((RawSuffix::E, false)))), - _ if j < 1e24 => Ok((i / 1e21, Some((RawSuffix::Z, false)))), - _ if j < 1e27 => Ok((i / 1e24, Some((RawSuffix::Y, false)))), - _ => Err("Number is too big and unsupported".to_owned()), - }, - Unit::Iec(with_i) => match j { - _ if j < IEC_BASES[1] => Ok((i, None)), - _ if j < IEC_BASES[2] => Ok((i / IEC_BASES[1], Some((RawSuffix::K, with_i)))), - _ if j < IEC_BASES[3] => Ok((i / IEC_BASES[2], Some((RawSuffix::M, with_i)))), - _ if j < IEC_BASES[4] => Ok((i / IEC_BASES[3], Some((RawSuffix::G, with_i)))), - _ if j < IEC_BASES[5] => Ok((i / IEC_BASES[4], Some((RawSuffix::T, with_i)))), - _ if j < IEC_BASES[6] => Ok((i / IEC_BASES[5], Some((RawSuffix::P, with_i)))), - _ if j < IEC_BASES[7] => Ok((i / IEC_BASES[6], Some((RawSuffix::E, with_i)))), - _ if j < IEC_BASES[8] => Ok((i / IEC_BASES[7], Some((RawSuffix::Z, with_i)))), - _ if j < IEC_BASES[9] => Ok((i / IEC_BASES[8], Some((RawSuffix::Y, with_i)))), - _ => Err("Number is too big and unsupported".to_owned()), - }, - Unit::Auto => Err("Unit 'auto' isn't supported with --to options".to_owned()), - Unit::None => Ok((i, None)), - } -} - -fn transform_to(s: f64, opts: &Transform) -> Result { - let (i2, s) = consider_suffix(s, &opts.unit)?; - Ok(match s { - None => format!("{}", i2), - Some(s) => format!("{:.1}{}", i2, DisplayableSuffix(s)), - }) -} - -fn format_string( - source: &str, - options: &NumfmtOptions, - implicit_padding: Option, -) -> Result { - let number = transform_to( - transform_from(source, &options.transform.from)?, - &options.transform.to, - )?; - - Ok(match implicit_padding.unwrap_or(options.padding) { - p if p == 0 => number, - p if p > 0 => format!("{:>padding$}", number, padding = p as usize), - p => format!("{: Result<()> { - let (prefix, field, suffix) = extract_field(&s)?; - - let implicit_padding = match !prefix.is_empty() && options.padding == 0 { - true => Some((prefix.len() + field.len()) as isize), - false => None, - }; - - let field = format_string(field, options, implicit_padding)?; - println!("{}{}", field, suffix); - - Ok(()) -} - fn parse_options(args: &ArgMatches) -> Result { let from = parse_unit(args.value_of(options::FROM).unwrap())?; let to = parse_unit(args.value_of(options::TO).unwrap())?; @@ -305,84 +119,32 @@ fn parse_options(args: &ArgMatches) -> Result { } }?; + let fields = match args.value_of(options::FIELD) { + Some("-") => vec![Range { + low: 1, + high: std::usize::MAX, + }], + Some(v) => Range::from_list(v)?, + None => unreachable!(), + }; + + let delimiter = args.value_of(options::DELIMITER).map_or(Ok(None), |arg| { + if arg.len() == 1 { + Ok(Some(arg.to_string())) + } else { + Err("the delimiter must be a single character".to_string()) + } + })?; + Ok(NumfmtOptions { transform, padding, header, + fields, + delimiter, }) } -/// Extract the field to convert from `line`. -/// -/// The field is the first sequence of non-whitespace characters in `line`. -/// -/// Returns a [`Result`] of `(prefix: &str, field: &str, suffix: &str)`, where -/// `prefix` contains any leading whitespace, `field` is the field to convert, -/// and `suffix` is everything after the field. `prefix` and `suffix` may be -/// empty. -/// -/// Returns an [`Err`] if `line` is empty or consists only of whitespace. -/// -/// Examples: -/// -/// ``` -/// use uu_numfmt::extract_field; -/// -/// assert_eq!("1K", extract_field("1K").unwrap().1); -/// -/// let (prefix, field, suffix) = extract_field(" 1K qux").unwrap(); -/// assert_eq!(" ", prefix); -/// assert_eq!("1K", field); -/// assert_eq!(" qux", suffix); -/// -/// assert!(extract_field("").is_err()); -/// ``` -pub fn extract_field(line: &str) -> Result<(&str, &str, &str)> { - let start = line - .find(|c: char| !c.is_whitespace()) - .ok_or("invalid number: ‘’")?; - - let prefix = &line[..start]; - - let mut field = &line[start..]; - - let suffix = match field.find(|c: char| c.is_whitespace()) { - Some(i) => { - let suffix = &field[i..]; - field = &field[..i]; - suffix - } - None => "", - }; - - Ok((prefix, field, suffix)) -} - -fn handle_args<'a>(args: impl Iterator, options: NumfmtOptions) -> Result<()> { - for l in args { - format_and_print(l, &options)?; - } - - Ok(()) -} - -fn handle_stdin(options: NumfmtOptions) -> Result<()> { - let stdin = std::io::stdin(); - let locked_stdin = stdin.lock(); - - let mut lines = locked_stdin.lines(); - for l in lines.by_ref().take(options.header) { - l.map(|s| println!("{}", s)).map_err(|e| e.to_string())?; - } - - for l in lines { - l.map_err(|e| e.to_string()) - .and_then(|l| format_and_print(&l, &options))?; - } - - Ok(()) -} - pub fn uumain(args: impl uucore::Args) -> i32 { let usage = get_usage(); @@ -391,6 +153,21 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .after_help(LONG_HELP) + .setting(AppSettings::AllowNegativeNumbers) + .arg( + Arg::with_name(options::DELIMITER) + .short("d") + .long(options::DELIMITER) + .value_name("X") + .help("use X instead of whitespace for field delimiter"), + ) + .arg( + Arg::with_name(options::FIELD) + .long(options::FIELD) + .help("replace the numbers in these input fields (default=1) see FIELDS below") + .value_name("FIELDS") + .default_value(options::FIELD_DEFAULT), + ) .arg( Arg::with_name(options::FROM) .long(options::FROM) @@ -438,6 +215,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { match result { Err(e) => { + std::io::stdout().flush().expect("error flushing stdout"); show_info!("{}", e); 1 } diff --git a/src/uu/numfmt/src/options.rs b/src/uu/numfmt/src/options.rs new file mode 100644 index 000000000..17f0a6fbe --- /dev/null +++ b/src/uu/numfmt/src/options.rs @@ -0,0 +1,27 @@ +use crate::units::Transform; +use uucore::ranges::Range; + +pub const DELIMITER: &str = "delimiter"; +pub const FIELD: &str = "field"; +pub const FIELD_DEFAULT: &str = "1"; +pub const FROM: &str = "from"; +pub const FROM_DEFAULT: &str = "none"; +pub const HEADER: &str = "header"; +pub const HEADER_DEFAULT: &str = "1"; +pub const NUMBER: &str = "NUMBER"; +pub const PADDING: &str = "padding"; +pub const TO: &str = "to"; +pub const TO_DEFAULT: &str = "none"; + +pub struct TransformOptions { + pub from: Transform, + pub to: Transform, +} + +pub struct NumfmtOptions { + pub transform: TransformOptions, + pub padding: isize, + pub header: usize, + pub fields: Vec, + pub delimiter: Option, +} diff --git a/src/uu/numfmt/src/units.rs b/src/uu/numfmt/src/units.rs new file mode 100644 index 000000000..5f9907bdf --- /dev/null +++ b/src/uu/numfmt/src/units.rs @@ -0,0 +1,67 @@ +use std::fmt; + +pub const SI_BASES: [f64; 10] = [1., 1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24, 1e27]; + +pub const IEC_BASES: [f64; 10] = [ + 1., + 1_024., + 1_048_576., + 1_073_741_824., + 1_099_511_627_776., + 1_125_899_906_842_624., + 1_152_921_504_606_846_976., + 1_180_591_620_717_411_303_424., + 1_208_925_819_614_629_174_706_176., + 1_237_940_039_285_380_274_899_124_224., +]; + +pub type WithI = bool; + +pub enum Unit { + Auto, + Si, + Iec(WithI), + None, +} + +pub struct Transform { + pub unit: Unit, +} + +pub type Result = std::result::Result; + +#[derive(Clone, Copy, Debug)] +pub enum RawSuffix { + K, + M, + G, + T, + P, + E, + Z, + Y, +} + +pub type Suffix = (RawSuffix, WithI); + +pub struct DisplayableSuffix(pub Suffix); + +impl fmt::Display for DisplayableSuffix { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let DisplayableSuffix((ref raw_suffix, ref with_i)) = *self; + match raw_suffix { + RawSuffix::K => write!(f, "K"), + RawSuffix::M => write!(f, "M"), + RawSuffix::G => write!(f, "G"), + RawSuffix::T => write!(f, "T"), + RawSuffix::P => write!(f, "P"), + RawSuffix::E => write!(f, "E"), + RawSuffix::Z => write!(f, "Z"), + RawSuffix::Y => write!(f, "Y"), + } + .and_then(|()| match with_i { + true => write!(f, "i"), + false => Ok(()), + }) + } +} diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 1c4f970e4..14aea59a7 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_od" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "od ~ (uutils) display formatted representation of input" @@ -19,7 +19,7 @@ byteorder = "1.3.2" getopts = "0.2.18" half = "1.6" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/od/src/multifilereader.rs b/src/uu/od/src/multifilereader.rs index e41c9e39b..1255da66d 100644 --- a/src/uu/od/src/multifilereader.rs +++ b/src/uu/od/src/multifilereader.rs @@ -24,7 +24,7 @@ pub trait HasError { } impl<'b> MultifileReader<'b> { - pub fn new<'a>(fnames: Vec>) -> MultifileReader<'a> { + pub fn new(fnames: Vec) -> MultifileReader { let mut mf = MultifileReader { ni: fnames, curr_file: None, // normally this means done; call next_file() diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index dbf784b76..47d3c29f8 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -472,11 +472,11 @@ fn print_bytes(prefix: &str, input_decoder: &MemoryDecoder, output_info: &Output /// /// `skip_bytes` is the number of bytes skipped from the input /// `read_bytes` is an optional limit to the number of bytes to read -fn open_input_peek_reader<'a>( - input_strings: &'a [String], +fn open_input_peek_reader( + input_strings: &[String], skip_bytes: usize, read_bytes: Option, -) -> PeekReader>> { +) -> PeekReader> { // should return "impl PeekRead + Read + HasError" when supported in (stable) rust let inputs = input_strings .iter() diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index 63e357cb2..3787ed270 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_paste" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "paste ~ (uutils) merge lines from inputs" @@ -15,8 +15,8 @@ edition = "2018" path = "src/paste.rs" [dependencies] -getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +clap = "2.33.3" +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index cff96d18e..751cc0a04 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -10,73 +10,82 @@ #[macro_use] extern crate uucore; +use clap::{App, Arg}; use std::fs::File; use std::io::{stdin, BufRead, BufReader, Read}; use std::iter::repeat; use std::path::Path; -static NAME: &str = "paste"; static VERSION: &str = env!("CARGO_PKG_VERSION"); +static ABOUT: &str = "Write lines consisting of the sequentially corresponding lines from each +FILE, separated by TABs, to standard output."; + +mod options { + pub const DELIMITER: &str = "delimiters"; + pub const SERIAL: &str = "serial"; + pub const FILE: &str = "file"; +} + +// Wraps BufReader and stdin +fn read_line( + reader: Option<&mut BufReader>, + buf: &mut String, +) -> std::io::Result { + match reader { + Some(reader) => reader.read_line(buf), + None => stdin().read_line(buf), + } +} pub fn uumain(args: impl uucore::Args) -> i32 { - let args = args.collect_str(); + let matches = App::new(executable!()) + .version(VERSION) + .about(ABOUT) + .arg( + Arg::with_name(options::SERIAL) + .long(options::SERIAL) + .short("s") + .help("paste one file at a time instead of in parallel"), + ) + .arg( + Arg::with_name(options::DELIMITER) + .long(options::DELIMITER) + .short("d") + .help("reuse characters from LIST instead of TABs") + .value_name("LIST") + .default_value("\t") + .hide_default_value(true), + ) + .arg( + Arg::with_name(options::FILE) + .value_name("FILE") + .multiple(true) + .default_value("-"), + ) + .get_matches_from(args); - let mut opts = getopts::Options::new(); - - opts.optflag( - "s", - "serial", - "paste one file at a time instead of in parallel", - ); - opts.optopt( - "d", - "delimiters", - "reuse characters from LIST instead of TABs", - "LIST", - ); - opts.optflag("h", "help", "display this help and exit"); - opts.optflag("V", "version", "output version information and exit"); - - let matches = match opts.parse(&args[1..]) { - Ok(m) => m, - Err(e) => crash!(1, "{}", e), - }; - - if matches.opt_present("help") { - let msg = format!( - "{0} {1} - -Usage: - {0} [OPTION]... [FILE]... - -Write lines consisting of the sequentially corresponding lines from each -FILE, separated by TABs, to standard output.", - NAME, VERSION - ); - print!("{}", opts.usage(&msg)); - } else if matches.opt_present("version") { - println!("{} {}", NAME, VERSION); - } else { - let serial = matches.opt_present("serial"); - let delimiters = matches - .opt_str("delimiters") - .unwrap_or_else(|| "\t".to_owned()); - paste(matches.free, serial, delimiters); - } + let serial = matches.is_present(options::SERIAL); + let delimiters = matches.value_of(options::DELIMITER).unwrap().to_owned(); + let files = matches + .values_of(options::FILE) + .unwrap() + .map(|s| s.to_owned()) + .collect(); + paste(files, serial, delimiters); 0 } fn paste(filenames: Vec, serial: bool, delimiters: String) { - let mut files: Vec>> = filenames + let mut files: Vec<_> = filenames .into_iter() .map(|name| { - BufReader::new(if name == "-" { - Box::new(stdin()) as Box + if name == "-" { + None } else { let r = crash_if_err!(1, File::open(Path::new(&name))); - Box::new(r) as Box - }) + Some(BufReader::new(r)) + } }) .collect(); @@ -91,7 +100,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: String) { let mut output = String::new(); loop { let mut line = String::new(); - match file.read_line(&mut line) { + match read_line(file.as_mut(), &mut line) { Ok(0) => break, Ok(_) => { output.push_str(line.trim_end()); @@ -113,7 +122,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: String) { eof_count += 1; } else { let mut line = String::new(); - match file.read_line(&mut line) { + match read_line(file.as_mut(), &mut line) { Ok(0) => { eof[i] = true; eof_count += 1; diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 9ff514fcc..452199f4f 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pathchk" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "pathchk ~ (uutils) diagnose invalid or non-portable PATHNAME" @@ -17,7 +17,7 @@ path = "src/pathchk.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index e52b0cdca..1618eab57 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pinky" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "pinky ~ (uutils) display user information" @@ -15,7 +15,7 @@ edition = "2018" path = "src/pinky.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["utmpx", "entries"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["utmpx", "entries"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index 6a330cc03..5266c1e03 100644 --- a/src/uu/printenv/Cargo.toml +++ b/src/uu/printenv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printenv" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "printenv ~ (uutils) display value of environment VAR" @@ -16,7 +16,7 @@ path = "src/printenv.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index d7166ae00..c6737d178 100644 --- a/src/uu/printf/Cargo.toml +++ b/src/uu/printf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printf" -version = "0.0.3" +version = "0.0.4" authors = [ "Nathan Ross", "uutils developers", @@ -19,7 +19,7 @@ path = "src/printf.rs" [dependencies] itertools = "0.8.0" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs index 33c3a7af5..bf21bf8f9 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/cninetyninehexfloatf.rs @@ -52,8 +52,7 @@ fn get_primitive_hex( last_dec_place: usize, capitalized: bool, ) -> FormatPrimitive { - let mut f: FormatPrimitive = Default::default(); - f.prefix = Some(String::from(if inprefix.sign == -1 { "-0x" } else { "0x" })); + let prefix = Some(String::from(if inprefix.sign == -1 { "-0x" } else { "0x" })); // assign the digits before and after the decimal points // to separate slices. If no digits after decimal point, @@ -97,7 +96,7 @@ fn get_primitive_hex( // conversion. The best way to do it is to just convert the floatnum // directly to base 2 and then at the end translate back to hex. let mantissa = 0; - f.suffix = Some({ + let suffix = Some({ let ind = if capitalized { "P" } else { "p" }; if mantissa >= 0 { format!("{}+{}", ind, mantissa) @@ -105,7 +104,11 @@ fn get_primitive_hex( format!("{}{}", ind, mantissa) } }); - f + FormatPrimitive { + prefix, + suffix, + ..Default::default() + } } fn to_hex(src: &str, before_decimal: bool) -> String { diff --git a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs index 489420c41..9231bd027 100644 --- a/src/uu/printf/src/tokenize/num_format/formatters/intf.rs +++ b/src/uu/printf/src/tokenize/num_format/formatters/intf.rs @@ -198,9 +198,10 @@ impl Formatter for Intf { // We always will have a format primitive to return Some(if convert_hints.len_digits == 0 || convert_hints.is_zero { // if non-digit or end is reached before a non-zero digit - let mut fmt_prim: FormatPrimitive = Default::default(); - fmt_prim.pre_decimal = Some(String::from("0")); - fmt_prim + FormatPrimitive { + pre_decimal: Some(String::from("0")), + ..Default::default() + } } else if !convert_hints.past_max { // if the number is or may be below the bounds limit let radix_out = match *field.field_char { diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index 26dea7b75..3a91feeb0 100644 --- a/src/uu/ptx/Cargo.toml +++ b/src/uu/ptx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ptx" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "ptx ~ (uutils) display a permuted index of input" @@ -21,7 +21,7 @@ libc = "0.2.42" memchr = "2.2.0" regex = "1.0.1" regex-syntax = "0.6.7" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 8421e52bc..bfcd6699f 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -95,12 +95,21 @@ impl WordFilter { if matches.opt_present("b") { crash!(1, "-b not implemented yet"); } - let reg = if matches.opt_present("W") { - matches.opt_str("W").expect("parsing options failed!") - } else if config.gnu_ext { - "\\w+".to_owned() + // Ignore empty string regex from cmd-line-args + let arg_reg: Option = if matches.opt_present("W") { + matches.opt_str("W").filter(|reg| !reg.is_empty()) } else { - "[^ \t\n]+".to_owned() + None + }; + let reg = match arg_reg { + Some(arg_reg) => arg_reg, + None => { + if config.gnu_ext { + "\\w+".to_owned() + } else { + "[^ \t\n]+".to_owned() + } + } }; WordFilter { only_specified: o, diff --git a/src/uu/pwd/Cargo.toml b/src/uu/pwd/Cargo.toml index 49cf18686..e074dc618 100644 --- a/src/uu/pwd/Cargo.toml +++ b/src/uu/pwd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pwd" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "pwd ~ (uutils) display current working directory" @@ -16,7 +16,7 @@ path = "src/pwd.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index bd89eb7a4..8e31f66f1 100644 --- a/src/uu/readlink/Cargo.toml +++ b/src/uu/readlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_readlink" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "readlink ~ (uutils) display resolved path of PATHNAME" @@ -17,7 +17,7 @@ path = "src/readlink.rs" [dependencies] clap = "2.33" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index 46678dd86..6f03086ba 100644 --- a/src/uu/realpath/Cargo.toml +++ b/src/uu/realpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_realpath" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "realpath ~ (uutils) display resolved absolute path of PATHNAME" @@ -16,7 +16,7 @@ path = "src/realpath.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index cdcb8e794..5cc8f3d9a 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -67,7 +67,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let paths: Vec = matches .values_of(ARG_FILES) .unwrap() - .map(|path| PathBuf::from(path)) + .map(PathBuf::from) .collect(); let strip = matches.is_present(OPT_STRIP); diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml index 9d87d5e23..1dc296ec6 100644 --- a/src/uu/relpath/Cargo.toml +++ b/src/uu/relpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_relpath" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "relpath ~ (uutils) display relative path of PATHNAME_TO from PATHNAME_FROM" @@ -16,7 +16,7 @@ path = "src/relpath.rs" [dependencies] getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 095764f72..b916412d8 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rm" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "rm ~ (uutils) remove PATHNAME" @@ -18,7 +18,7 @@ path = "src/rm.rs" clap = "2.33" walkdir = "2.2" remove_dir_all = "0.5.1" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 4c81c97cc..466a8d6c1 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -48,6 +48,7 @@ static OPT_PRESERVE_ROOT: &str = "preserve-root"; static OPT_PROMPT: &str = "prompt"; static OPT_PROMPT_MORE: &str = "prompt-more"; static OPT_RECURSIVE: &str = "recursive"; +static OPT_RECURSIVE_R: &str = "recursive_R"; static OPT_VERBOSE: &str = "verbose"; static ARG_FILES: &str = "files"; @@ -58,7 +59,7 @@ fn get_usage() -> String { fn get_long_usage() -> String { String::from( - "By default, rm does not remove directories. Use the --recursive (-r) + "By default, rm does not remove directories. Use the --recursive (-r or -R) option to remove each listed directory, too, along with all of its contents To remove a file whose name starts with a '-', for example '-foo', @@ -82,7 +83,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .after_help(&long_usage[..]) - // TODO: make getopts support -R in addition to -r .arg( Arg::with_name(OPT_FORCE) @@ -128,6 +128,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .long(OPT_RECURSIVE) .help("remove directories and their contents recursively") ) + .arg( + // To mimic GNU's behavior we also want the '-R' flag. However, using clap's + // alias method 'visible_alias("R")' would result in a long '--R' flag. + Arg::with_name(OPT_RECURSIVE_R).short("R") + .help("Equivalent to -r") + ) .arg( Arg::with_name(OPT_DIR) .short("d") @@ -182,7 +188,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { }, one_fs: matches.is_present(OPT_ONE_FILE_SYSTEM), preserve_root: !matches.is_present(OPT_NO_PRESERVE_ROOT), - recursive: matches.is_present(OPT_RECURSIVE), + recursive: matches.is_present(OPT_RECURSIVE) || matches.is_present(OPT_RECURSIVE_R), dir: matches.is_present(OPT_DIR), verbose: matches.is_present(OPT_VERBOSE), }; @@ -283,7 +289,7 @@ fn handle_dir(path: &Path, options: &Options) -> bool { had_err = true; } else { show_error!( - "could not remove directory '{}' (did you mean to pass '-r'?)", + "could not remove directory '{}' (did you mean to pass '-r' or '-R'?)", path.display() ); had_err = true; diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index 639e3f1cb..9d6bb03cc 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rmdir" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "rmdir ~ (uutils) remove empty DIRECTORY" @@ -16,7 +16,7 @@ path = "src/rmdir.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index df9abe4d2..d7ee72b68 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_seq" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "seq ~ (uutils) display a sequence of numbers" @@ -16,7 +16,7 @@ path = "src/seq.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index bf23cc6ee..72e6119a8 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shred" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "shred ~ (uutils) hide former FILE contents with repeated overwrites" @@ -20,7 +20,7 @@ getopts = "0.2.18" libc = "0.2.42" rand = "0.5" time = "0.1.40" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index 6e777eab5..b78d4fc04 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shuf" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "shuf ~ (uutils) display random permutations of input lines" @@ -17,7 +17,7 @@ path = "src/shuf.rs" [dependencies] getopts = "0.2.18" rand = "0.5" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index 9f4bb01c4..278e872fb 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -97,9 +97,9 @@ With no FILE, or when FILE is -, read standard input.", }; let repeat = matches.opt_present("repeat"); let sep = if matches.opt_present("zero-terminated") { - 0x00 as u8 + 0x00_u8 } else { - 0x0a as u8 + 0x0a_u8 }; let count = match matches.opt_str("head-count") { Some(cnt) => match cnt.parse::() { diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index 396f6424d..0ac5d6519 100644 --- a/src/uu/sleep/Cargo.toml +++ b/src/uu/sleep/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sleep" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "sleep ~ (uutils) pause for DURATION" @@ -15,8 +15,8 @@ edition = "2018" path = "src/sleep.rs" [dependencies] -getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["parse_time"] } +clap = "2.33" +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["parse_time"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index f08a6d3a4..5c1f06e5e 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -11,55 +11,56 @@ extern crate uucore; use std::thread; use std::time::Duration; -static NAME: &str = "sleep"; +use clap::{App, Arg}; + static VERSION: &str = env!("CARGO_PKG_VERSION"); - -pub fn uumain(args: impl uucore::Args) -> i32 { - let args = args.collect_str(); - - let mut opts = getopts::Options::new(); - opts.optflag("h", "help", "display this help and exit"); - opts.optflag("V", "version", "output version information and exit"); - - let matches = match opts.parse(&args[1..]) { - Ok(m) => m, - Err(f) => { - show_error!("{}", f); - return 1; - } - }; - - if matches.opt_present("help") { - let msg = format!( - "{0} {1} - -Usage: - {0} NUMBER[SUFFIX] -or - {0} OPTION - -Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), +static ABOUT: &str = "Pause for NUMBER seconds."; +static LONG_HELP: &str = "Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time -specified by the sum of their values.", - NAME, VERSION - ); - print!("{}", opts.usage(&msg)); - } else if matches.opt_present("version") { - println!("{} {}", NAME, VERSION); - } else if matches.free.is_empty() { - show_error!("missing an argument"); - show_error!("for help, try '{0} --help'", NAME); - return 1; - } else { - sleep(matches.free); +specified by the sum of their values."; + +mod options { + pub const NUMBER: &str = "NUMBER"; +} + +fn get_usage() -> String { + format!( + "{0} {1}[SUFFIX]... \n {0} OPTION", + executable!(), + options::NUMBER + ) +} + +pub fn uumain(args: impl uucore::Args) -> i32 { + let usage = get_usage(); + + let matches = App::new(executable!()) + .version(VERSION) + .about(ABOUT) + .usage(&usage[..]) + .after_help(LONG_HELP) + .arg( + Arg::with_name(options::NUMBER) + .long(options::NUMBER) + .help("pause for NUMBER seconds") + .value_name(options::NUMBER) + .index(1) + .multiple(true) + .required(true), + ) + .get_matches_from(args); + + if let Some(values) = matches.values_of(options::NUMBER) { + let numbers = values.collect(); + sleep(numbers); } 0 } -fn sleep(args: Vec) { +fn sleep(args: Vec<&str>) { let sleep_dur = args.iter().fold( Duration::new(0, 0), diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index b95ece92f..5158f6e52 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sort" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "sort ~ (uutils) sort input lines" @@ -18,7 +18,7 @@ path = "src/sort.rs" clap = "2.33" itertools = "0.8.0" semver = "0.9.0" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index ad0fb3906..7c3f1a56e 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_split" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "split ~ (uutils) split input into output files" @@ -16,7 +16,7 @@ path = "src/split.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/split/src/platform/unix.rs b/src/uu/split/src/platform/unix.rs index 331b31115..20d9d637b 100644 --- a/src/uu/split/src/platform/unix.rs +++ b/src/uu/split/src/platform/unix.rs @@ -4,7 +4,7 @@ use std::io::{BufWriter, Result}; use std::process::{Child, Command, Stdio}; /// A writer that writes to a shell_process' stdin /// -/// We use a shell process (not directy calling a sub-process) so we can forward the name of the +/// We use a shell process (not directly calling a sub-process) so we can forward the name of the /// corresponding output file (xaa, xab, xac… ). This is the way it was implemented in GNU split. struct FilterWriter { /// Running shell process @@ -68,12 +68,13 @@ impl FilterWriter { // set $FILE, save previous value (if there was one) let _with_env_var_set = WithEnvVarSet::new("FILE", &filepath); - let shell_process = Command::new(env::var("SHELL").unwrap_or("/bin/sh".to_owned())) - .arg("-c") - .arg(command) - .stdin(Stdio::piped()) - .spawn() - .expect("Couldn't spawn filter command"); + let shell_process = + Command::new(env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_owned())) + .arg("-c") + .arg(command) + .stdin(Stdio::piped()) + .spawn() + .expect("Couldn't spawn filter command"); FilterWriter { shell_process } } diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 851edc4b5..4f80e25a3 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -150,7 +150,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .value_of(OPT_SUFFIX_LENGTH) .unwrap() .parse() - .expect(format!("Invalid number for {}", OPT_SUFFIX_LENGTH).as_str()); + .unwrap_or_else(|_| panic!("Invalid number for {}", OPT_SUFFIX_LENGTH)); settings.numeric_suffix = matches.occurrences_of(OPT_NUMERIC_SUFFIXES) > 0; settings.additional_suffix = matches.value_of(OPT_ADDITIONAL_SUFFIX).unwrap().to_owned(); diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index e24a8ac9d..52ea88110 100644 --- a/src/uu/stat/Cargo.toml +++ b/src/uu/stat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stat" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "stat ~ (uutils) display FILE status" @@ -17,7 +17,7 @@ path = "src/stat.rs" [dependencies] clap = "2.33" time = "0.1.40" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "libc"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "libc"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/stat/src/fsext.rs b/src/uu/stat/src/fsext.rs index 11c8f8095..d90099892 100644 --- a/src/uu/stat/src/fsext.rs +++ b/src/uu/stat/src/fsext.rs @@ -149,7 +149,7 @@ use std::path::Path; #[cfg(any( target_os = "linux", - target_os = "macos", + target_vendor = "apple", target_os = "android", target_os = "freebsd" ))] @@ -165,7 +165,7 @@ use uucore::libc::statvfs as Sstatfs; #[cfg(any( target_os = "linux", - target_os = "macos", + target_vendor = "apple", target_os = "android", target_os = "freebsd" ))] @@ -211,11 +211,11 @@ impl FsMeta for Sstatfs { fn free_fnodes(&self) -> u64 { self.f_ffree as u64 } - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] + #[cfg(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd"))] fn fs_type(&self) -> i64 { self.f_type as i64 } - #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd")))] + #[cfg(not(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd")))] fn fs_type(&self) -> i64 { // FIXME: statvfs doesn't have an equivalent, so we need to do something else unimplemented!() @@ -225,12 +225,12 @@ impl FsMeta for Sstatfs { fn iosize(&self) -> u64 { self.f_frsize as u64 } - #[cfg(any(target_os = "macos", target_os = "freebsd"))] + #[cfg(any(target_vendor = "apple", target_os = "freebsd"))] fn iosize(&self) -> u64 { self.f_iosize as u64 } // XXX: dunno if this is right - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))] + #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] fn iosize(&self) -> u64 { self.f_bsize as u64 } @@ -241,13 +241,13 @@ impl FsMeta for Sstatfs { // // Solaris, Irix and POSIX have a system call statvfs(2) that returns a // struct statvfs, containing an unsigned long f_fsid - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "linux"))] + #[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux"))] fn fsid(&self) -> u64 { let f_fsid: &[u32; 2] = unsafe { &*(&self.f_fsid as *const uucore::libc::fsid_t as *const [u32; 2]) }; (u64::from(f_fsid[0])) << 32 | u64::from(f_fsid[1]) } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))] + #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] fn fsid(&self) -> u64 { self.f_fsid as u64 } @@ -256,7 +256,7 @@ impl FsMeta for Sstatfs { fn namelen(&self) -> u64 { self.f_namelen as u64 } - #[cfg(target_os = "macos")] + #[cfg(target_vendor = "apple")] fn namelen(&self) -> u64 { 1024 } @@ -265,7 +265,7 @@ impl FsMeta for Sstatfs { self.f_namemax as u64 } // XXX: should everything just use statvfs? - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))] + #[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))] fn namelen(&self) -> u64 { self.f_namemax as u64 } diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 322f224b3..5216fb293 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -87,11 +87,13 @@ macro_rules! print_adjusted { static ABOUT: &str = "Display file or file system status."; static VERSION: &str = env!("CARGO_PKG_VERSION"); -static OPT_DEREFERENCE: &str = "dereference"; -static OPT_FILE_SYSTEM: &str = "file-system"; -static OPT_FORMAT: &str = "format"; -static OPT_PRINTF: &str = "printf"; -static OPT_TERSE: &str = "terse"; +pub mod options { + pub static DEREFERENCE: &str = "dereference"; + pub static FILE_SYSTEM: &str = "file-system"; + pub static FORMAT: &str = "format"; + pub static PRINTF: &str = "printf"; + pub static TERSE: &str = "terse"; +} static ARG_FILES: &str = "files"; @@ -464,15 +466,17 @@ impl Stater { .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); - let fmtstr = if matches.is_present(OPT_PRINTF) { - matches.value_of(OPT_PRINTF).expect("Invalid format string") + let fmtstr = if matches.is_present(options::PRINTF) { + matches + .value_of(options::PRINTF) + .expect("Invalid format string") } else { - matches.value_of(OPT_FORMAT).unwrap_or("") + matches.value_of(options::FORMAT).unwrap_or("") }; - let use_printf = matches.is_present(OPT_PRINTF); - let terse = matches.is_present(OPT_TERSE); - let showfs = matches.is_present(OPT_FILE_SYSTEM); + let use_printf = matches.is_present(options::PRINTF); + let terse = matches.is_present(options::TERSE); + let showfs = matches.is_present(options::FILE_SYSTEM); let default_tokens = if fmtstr.is_empty() { Stater::generate_tokens(&Stater::default_fmt(showfs, terse, false), use_printf).unwrap() @@ -501,7 +505,7 @@ impl Stater { }; Ok(Stater { - follow: matches.is_present(OPT_DEREFERENCE), + follow: matches.is_present(options::DEREFERENCE), showfs, from_user: !fmtstr.is_empty(), files, @@ -955,27 +959,27 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .usage(&usage[..]) .after_help(&long_usage[..]) .arg( - Arg::with_name(OPT_DEREFERENCE) + Arg::with_name(options::DEREFERENCE) .short("L") - .long(OPT_DEREFERENCE) + .long(options::DEREFERENCE) .help("follow links"), ) .arg( - Arg::with_name(OPT_FILE_SYSTEM) + Arg::with_name(options::FILE_SYSTEM) .short("f") - .long(OPT_FILE_SYSTEM) + .long(options::FILE_SYSTEM) .help("display file system status instead of file status"), ) .arg( - Arg::with_name(OPT_TERSE) + Arg::with_name(options::TERSE) .short("t") - .long(OPT_TERSE) + .long(options::TERSE) .help("print the information in terse form"), ) .arg( - Arg::with_name(OPT_FORMAT) + Arg::with_name(options::FORMAT) .short("c") - .long(OPT_FORMAT) + .long(options::FORMAT) .help( "use the specified FORMAT instead of the default; output a newline after each use of FORMAT", @@ -983,8 +987,8 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .value_name("FORMAT"), ) .arg( - Arg::with_name(OPT_PRINTF) - .long(OPT_PRINTF) + Arg::with_name(options::PRINTF) + .long(options::PRINTF) .value_name("FORMAT") .help( "like --format, but interpret backslash escapes, diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index 1a317e6ed..7a80e99ae 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "stdbuf ~ (uutils) run COMMAND with modified standard stream buffering" @@ -17,11 +17,11 @@ path = "src/stdbuf.rs" [dependencies] getopts = "0.2.18" tempfile = "3.1" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [build-dependencies] -libstdbuf = { version="0.0.3", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" } +libstdbuf = { version="0.0.4", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" } [[bin]] name = "stdbuf" diff --git a/src/uu/stdbuf/build.rs b/src/uu/stdbuf/build.rs index c005072d9..b14d503cf 100644 --- a/src/uu/stdbuf/build.rs +++ b/src/uu/stdbuf/build.rs @@ -4,12 +4,12 @@ use std::env; use std::fs; use std::path::Path; -#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))] +#[cfg(not(any(target_vendor = "apple", target_os = "windows")))] mod platform { pub const DYLIB_EXT: &str = ".so"; } -#[cfg(any(target_os = "macos", target_os = "ios"))] +#[cfg(any(target_vendor = "apple"))] mod platform { pub const DYLIB_EXT: &str = ".dylib"; } diff --git a/src/uu/stdbuf/src/libstdbuf/Cargo.toml b/src/uu/stdbuf/src/libstdbuf/Cargo.toml index 7bd34012d..ac9c7230f 100644 --- a/src/uu/stdbuf/src/libstdbuf/Cargo.toml +++ b/src/uu/stdbuf/src/libstdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf_libstdbuf" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "stdbuf/libstdbuf ~ (uutils); dynamic library required for stdbuf" @@ -19,7 +19,7 @@ crate-type = ["cdylib", "rlib"] # XXX: note: the rlib is just to prevent Cargo f [dependencies] cpp = "0.5" libc = "0.2" -uucore = { version=">=0.0.6", package="uucore", path="../../../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../../../uucore_procs" } [build-dependencies] diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 86523144c..67ed9a838 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -57,7 +57,7 @@ fn preload_strings() -> (&'static str, &'static str) { ("LD_PRELOAD", "so") } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn preload_strings() -> (&'static str, &'static str) { ("DYLD_LIBRARY_PATH", "dylib") } @@ -67,7 +67,7 @@ fn preload_strings() -> (&'static str, &'static str) { target_os = "freebsd", target_os = "netbsd", target_os = "dragonflybsd", - target_os = "macos" + target_vendor = "apple" )))] fn preload_strings() -> (&'static str, &'static str) { crash!(1, "Command not supported for this operating system!") diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index 4bc82ab5b..a880ba1f7 100644 --- a/src/uu/sum/Cargo.toml +++ b/src/uu/sum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sum" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "sum ~ (uutils) display checksum and block counts for input" @@ -16,7 +16,7 @@ path = "src/sum.rs" [dependencies] getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index 7a7a83a43..4cbf69a41 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sync" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "sync ~ (uutils) synchronize cache writes to storage" @@ -17,7 +17,7 @@ path = "src/sync.rs" [dependencies] clap = "2.33" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["wide"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["wide"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] } diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index 5d4cb4395..985e7580d 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -19,8 +19,10 @@ static EXIT_ERR: i32 = 1; static ABOUT: &str = "Synchronize cached writes to persistent storage"; static VERSION: &str = env!("CARGO_PKG_VERSION"); -static OPT_FILE_SYSTEM: &str = "file-system"; -static OPT_DATA: &str = "data"; +pub mod options { + pub static FILE_SYSTEM: &str = "file-system"; + pub static DATA: &str = "data"; +} static ARG_FILES: &str = "files"; @@ -170,17 +172,17 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .arg( - Arg::with_name(OPT_FILE_SYSTEM) + Arg::with_name(options::FILE_SYSTEM) .short("f") - .long(OPT_FILE_SYSTEM) - .conflicts_with(OPT_DATA) + .long(options::FILE_SYSTEM) + .conflicts_with(options::DATA) .help("sync the file systems that contain the files (Linux and Windows only)"), ) .arg( - Arg::with_name(OPT_DATA) + Arg::with_name(options::DATA) .short("d") - .long(OPT_DATA) - .conflicts_with(OPT_FILE_SYSTEM) + .long(options::DATA) + .conflicts_with(options::FILE_SYSTEM) .help("sync only file data, no unneeded metadata (Linux only)"), ) .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) @@ -197,10 +199,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } - if matches.is_present(OPT_FILE_SYSTEM) { + if matches.is_present(options::FILE_SYSTEM) { #[cfg(any(target_os = "linux", target_os = "windows"))] syncfs(files); - } else if matches.is_present(OPT_DATA) { + } else if matches.is_present(options::DATA) { #[cfg(target_os = "linux")] fdatasync(files); } else { diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index b62875372..15e743006 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tac" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "tac ~ (uutils) concatenate and display input lines in reverse order" @@ -16,7 +16,7 @@ path = "src/tac.rs" [dependencies] getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index f94283089..6e51e3e35 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tail" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "tail ~ (uutils) display the last lines of input" @@ -17,7 +17,7 @@ path = "src/tail.rs" [dependencies] clap = "2.33" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] } diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index 2276885e0..cd391a53e 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -27,15 +27,19 @@ use std::path::Path; use std::thread::sleep; use std::time::Duration; -static OPT_BYTES: &str = "bytes"; -static OPT_FOLLOW: &str = "follow"; -static OPT_LINES: &str = "lines"; -static OPT_PID: &str = "pid"; -static OPT_QUIET: &str = "quiet"; -static OPT_SILENT: &str = "silent"; -static OPT_SLEEP_INT: &str = "sleep-interval"; -static OPT_VERBOSE: &str = "verbose"; -static OPT_ZERO_TERM: &str = "zero-terminated"; +pub mod options { + pub mod verbosity { + pub static QUIET: &str = "quiet"; + pub static SILENT: &str = "silent"; + pub static VERBOSE: &str = "verbose"; + } + pub static BYTES: &str = "bytes"; + pub static FOLLOW: &str = "follow"; + pub static LINES: &str = "lines"; + pub static PID: &str = "pid"; + pub static SLEEP_INT: &str = "sleep-interval"; + pub static ZERO_TERM: &str = "zero-terminated"; +} static ARG_FILES: &str = "files"; @@ -72,58 +76,58 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .version(crate_version!()) .about("output the last part of files") .arg( - Arg::with_name(OPT_BYTES) + Arg::with_name(options::BYTES) .short("c") - .long(OPT_BYTES) + .long(options::BYTES) .takes_value(true) .help("Number of bytes to print"), ) .arg( - Arg::with_name(OPT_FOLLOW) + Arg::with_name(options::FOLLOW) .short("f") - .long(OPT_FOLLOW) + .long(options::FOLLOW) .help("Print the file as it grows"), ) .arg( - Arg::with_name(OPT_LINES) + Arg::with_name(options::LINES) .short("n") - .long(OPT_LINES) + .long(options::LINES) .takes_value(true) .help("Number of lines to print"), ) .arg( - Arg::with_name(OPT_PID) - .long(OPT_PID) + Arg::with_name(options::PID) + .long(options::PID) .takes_value(true) .help("with -f, terminate after process ID, PID dies"), ) .arg( - Arg::with_name(OPT_QUIET) + Arg::with_name(options::verbosity::QUIET) .short("q") - .long(OPT_QUIET) + .long(options::verbosity::QUIET) .help("never output headers giving file names"), ) .arg( - Arg::with_name(OPT_SILENT) - .long(OPT_SILENT) + Arg::with_name(options::verbosity::SILENT) + .long(options::verbosity::SILENT) .help("synonym of --quiet"), ) .arg( - Arg::with_name(OPT_SLEEP_INT) + Arg::with_name(options::SLEEP_INT) .short("s") - .long(OPT_SLEEP_INT) + .long(options::SLEEP_INT) .help("Number or seconds to sleep between polling the file when running with -f"), ) .arg( - Arg::with_name(OPT_VERBOSE) + Arg::with_name(options::verbosity::VERBOSE) .short("v") - .long(OPT_VERBOSE) + .long(options::verbosity::VERBOSE) .help("always output headers giving file names"), ) .arg( - Arg::with_name(OPT_ZERO_TERM) + Arg::with_name(options::ZERO_TERM) .short("z") - .long(OPT_ZERO_TERM) + .long(options::ZERO_TERM) .help("Line delimiter is NUL, not newline"), ) .arg( @@ -135,9 +139,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let matches = app.get_matches_from(args); - settings.follow = matches.is_present(OPT_FOLLOW); + settings.follow = matches.is_present(options::FOLLOW); if settings.follow { - if let Some(n) = matches.value_of(OPT_SLEEP_INT) { + if let Some(n) = matches.value_of(options::SLEEP_INT) { let parsed: Option = n.parse().ok(); if let Some(m) = parsed { settings.sleep_msec = m * 1000 @@ -145,7 +149,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } - if let Some(pid_str) = matches.value_of(OPT_PID) { + if let Some(pid_str) = matches.value_of(options::PID) { if let Ok(pid) = pid_str.parse() { settings.pid = pid; if pid != 0 { @@ -161,7 +165,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } - match matches.value_of(OPT_LINES) { + match matches.value_of(options::LINES) { Some(n) => { let mut slice: &str = n; if slice.chars().next().unwrap_or('_') == '+' { @@ -177,7 +181,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } None => { - if let Some(n) = matches.value_of(OPT_BYTES) { + if let Some(n) = matches.value_of(options::BYTES) { let mut slice: &str = n; if slice.chars().next().unwrap_or('_') == '+' { settings.beginning = true; @@ -194,14 +198,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } }; - if matches.is_present(OPT_ZERO_TERM) { + if matches.is_present(options::ZERO_TERM) { if let FilterMode::Lines(count, _) = settings.mode { settings.mode = FilterMode::Lines(count, 0); } } - let verbose = matches.is_present(OPT_VERBOSE); - let quiet = matches.is_present(OPT_QUIET) || matches.is_present(OPT_SILENT); + let verbose = matches.is_present(options::verbosity::VERBOSE); + let quiet = matches.is_present(options::verbosity::QUIET) + || matches.is_present(options::verbosity::SILENT); let files: Vec = matches .values_of(ARG_FILES) @@ -270,7 +275,11 @@ impl Error for ParseSizeErr { impl fmt::Display for ParseSizeErr { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "{}", self.to_string()) + let s = match self { + ParseSizeErr::ParseFailure(s) => s, + ParseSizeErr::SizeTooBig(s) => s, + }; + write!(f, "{}", s) } } diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index 931a010e5..ee18e888f 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tee" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "tee ~ (uutils) display input and copy to FILE" @@ -17,7 +17,7 @@ path = "src/tee.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["libc"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["libc"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index f076f242c..6471c9e62 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_test" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "test ~ (uutils) evaluate comparison and file type expressions" @@ -16,7 +16,7 @@ path = "src/test.rs" [dependencies] libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "redox")'.dependencies] diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 0a920d988..c13a98d19 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_timeout" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "timeout ~ (uutils) run COMMAND with a DURATION time limit" @@ -17,7 +17,7 @@ path = "src/timeout.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["parse_time", "process", "signals"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["parse_time", "process", "signals"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index c88808224..fc021c096 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_touch" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "touch ~ (uutils) change FILE timestamps" @@ -18,7 +18,7 @@ path = "src/touch.rs" filetime = "0.2.1" clap = "2.33" time = "0.1.40" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["libc"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["libc"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 913a5be9b..39405900e 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -13,7 +13,7 @@ pub extern crate filetime; #[macro_use] extern crate uucore; -use clap::{App, Arg}; +use clap::{App, Arg, ArgGroup}; use filetime::*; use std::fs::{self, File}; use std::io::Error; @@ -21,34 +21,32 @@ use std::path::Path; static VERSION: &str = env!("CARGO_PKG_VERSION"); static ABOUT: &str = "Update the access and modification times of each FILE to the current time."; -static OPT_ACCESS: &str = "access"; -static OPT_CURRENT: &str = "current"; -static OPT_DATE: &str = "date"; -static OPT_MODIFICATION: &str = "modification"; -static OPT_NO_CREATE: &str = "no-create"; -static OPT_NO_DEREF: &str = "no-dereference"; -static OPT_REFERENCE: &str = "reference"; -static OPT_TIME: &str = "time"; +pub mod options { + // Both SOURCES and sources are needed as we need to be able to refer to the ArgGroup. + pub static SOURCES: &str = "sources"; + pub mod sources { + pub static DATE: &str = "date"; + pub static REFERENCE: &str = "reference"; + pub static CURRENT: &str = "current"; + } + pub static ACCESS: &str = "access"; + pub static MODIFICATION: &str = "modification"; + pub static NO_CREATE: &str = "no-create"; + pub static NO_DEREF: &str = "no-dereference"; + pub static TIME: &str = "time"; +} static ARG_FILES: &str = "files"; -// Since touch's date/timestamp parsing doesn't account for timezone, the -// returned value from time::strptime() is UTC. We get system's timezone to -// localize the time. -macro_rules! to_local( - ($exp:expr) => ({ - let mut tm = $exp; - tm.tm_utcoff = time::now().tm_utcoff; - tm - }) -); +fn to_local(mut tm: time::Tm) -> time::Tm { + tm.tm_utcoff = time::now().tm_utcoff; + tm +} -macro_rules! local_tm_to_filetime( - ($exp:expr) => ({ - let ts = $exp.to_timespec(); - FileTime::from_unix_time(ts.sec as i64, ts.nsec as u32) - }) -); +fn local_tm_to_filetime(tm: time::Tm) -> FileTime { + let ts = tm.to_timespec(); + FileTime::from_unix_time(ts.sec as i64, ts.nsec as u32) +} fn get_usage() -> String { format!("{0} [OPTION]... [USER]", executable!()) @@ -62,54 +60,54 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .arg( - Arg::with_name(OPT_ACCESS) + Arg::with_name(options::ACCESS) .short("a") .help("change only the access time"), ) .arg( - Arg::with_name(OPT_CURRENT) + Arg::with_name(options::sources::CURRENT) .short("t") .help("use [[CC]YY]MMDDhhmm[.ss] instead of the current time") .value_name("STAMP") .takes_value(true), ) .arg( - Arg::with_name(OPT_DATE) + Arg::with_name(options::sources::DATE) .short("d") - .long(OPT_DATE) + .long(options::sources::DATE) .help("parse argument and use it instead of current time") .value_name("STRING"), ) .arg( - Arg::with_name(OPT_MODIFICATION) + Arg::with_name(options::MODIFICATION) .short("m") .help("change only the modification time"), ) .arg( - Arg::with_name(OPT_NO_CREATE) + Arg::with_name(options::NO_CREATE) .short("c") - .long(OPT_NO_CREATE) + .long(options::NO_CREATE) .help("do not create any files"), ) .arg( - Arg::with_name(OPT_NO_DEREF) + Arg::with_name(options::NO_DEREF) .short("h") - .long(OPT_NO_DEREF) + .long(options::NO_DEREF) .help( "affect each symbolic link instead of any referenced file \ (only for systems that can change the timestamps of a symlink)", ), ) .arg( - Arg::with_name(OPT_REFERENCE) + Arg::with_name(options::sources::REFERENCE) .short("r") - .long(OPT_REFERENCE) + .long(options::sources::REFERENCE) .help("use this file's times instead of the current time") .value_name("FILE"), ) .arg( - Arg::with_name(OPT_TIME) - .long(OPT_TIME) + Arg::with_name(options::TIME) + .long(options::TIME) .help( "change only the specified time: \"access\", \"atime\", or \ \"use\" are equivalent to -a; \"modify\" or \"mtime\" are \ @@ -125,6 +123,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .takes_value(true) .min_values(1), ) + .group(ArgGroup::with_name(options::SOURCES).args(&[ + options::sources::CURRENT, + options::sources::DATE, + options::sources::REFERENCE, + ])) .get_matches_from(args); let files: Vec = matches @@ -132,30 +135,27 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); - if matches.is_present(OPT_DATE) - && (matches.is_present(OPT_REFERENCE) || matches.is_present(OPT_CURRENT)) - || matches.is_present(OPT_REFERENCE) - && (matches.is_present(OPT_DATE) || matches.is_present(OPT_CURRENT)) - || matches.is_present(OPT_CURRENT) - && (matches.is_present(OPT_DATE) || matches.is_present(OPT_REFERENCE)) - { - panic!("Invalid options: cannot specify reference time from more than one source"); - } - - let (mut atime, mut mtime) = if matches.is_present(OPT_REFERENCE) { + let (mut atime, mut mtime) = if matches.is_present(options::sources::REFERENCE) { stat( - &matches.value_of(OPT_REFERENCE).unwrap()[..], - !matches.is_present(OPT_NO_DEREF), + &matches.value_of(options::sources::REFERENCE).unwrap()[..], + !matches.is_present(options::NO_DEREF), ) - } else if matches.is_present(OPT_DATE) || matches.is_present(OPT_CURRENT) { - let timestamp = if matches.is_present(OPT_DATE) { - parse_date(matches.value_of(OPT_DATE).unwrap().as_ref()) + } else if matches.is_present(options::sources::DATE) + || matches.is_present(options::sources::CURRENT) + { + let timestamp = if matches.is_present(options::sources::DATE) { + parse_date(matches.value_of(options::sources::DATE).unwrap().as_ref()) } else { - parse_timestamp(matches.value_of(OPT_CURRENT).unwrap().as_ref()) + parse_timestamp( + matches + .value_of(options::sources::CURRENT) + .unwrap() + .as_ref(), + ) }; (timestamp, timestamp) } else { - let now = local_tm_to_filetime!(time::now()); + let now = local_tm_to_filetime(time::now()); (now, now) }; @@ -164,7 +164,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { if !Path::new(path).exists() { // no-dereference included here for compatibility - if matches.is_present(OPT_NO_CREATE) || matches.is_present(OPT_NO_DEREF) { + if matches.is_present(options::NO_CREATE) || matches.is_present(options::NO_DEREF) { continue; } @@ -174,24 +174,21 @@ pub fn uumain(args: impl uucore::Args) -> i32 { }; // Minor optimization: if no reference time was specified, we're done. - if !(matches.is_present(OPT_DATE) - || matches.is_present(OPT_REFERENCE) - || matches.is_present(OPT_CURRENT)) - { + if !matches.is_present(options::SOURCES) { continue; } } // If changing "only" atime or mtime, grab the existing value of the other. // Note that "-a" and "-m" may be passed together; this is not an xor. - if matches.is_present(OPT_ACCESS) - || matches.is_present(OPT_MODIFICATION) - || matches.is_present(OPT_TIME) + if matches.is_present(options::ACCESS) + || matches.is_present(options::MODIFICATION) + || matches.is_present(options::TIME) { - let st = stat(path, !matches.is_present(OPT_NO_DEREF)); - let time = matches.value_of(OPT_TIME).unwrap_or(""); + let st = stat(path, !matches.is_present(options::NO_DEREF)); + let time = matches.value_of(options::TIME).unwrap_or(""); - if !(matches.is_present(OPT_ACCESS) + if !(matches.is_present(options::ACCESS) || time.contains(&"access".to_owned()) || time.contains(&"atime".to_owned()) || time.contains(&"use".to_owned())) @@ -199,7 +196,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { atime = st.0; } - if !(matches.is_present(OPT_MODIFICATION) + if !(matches.is_present(options::MODIFICATION) || time.contains(&"modify".to_owned()) || time.contains(&"mtime".to_owned())) { @@ -207,7 +204,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { } } - if matches.is_present(OPT_NO_DEREF) { + if matches.is_present(options::NO_DEREF) { if let Err(e) = set_symlink_file_times(path, atime, mtime) { show_warning!("cannot touch '{}': {}", path, e); } @@ -246,7 +243,7 @@ fn parse_date(str: &str) -> FileTime { // not about to implement GNU parse_datetime. // http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=lib/parse-datetime.y match time::strptime(str, "%c") { - Ok(tm) => local_tm_to_filetime!(to_local!(tm)), + Ok(tm) => local_tm_to_filetime(to_local(tm)), Err(e) => panic!("Unable to parse date\n{}", e), } } @@ -264,7 +261,7 @@ fn parse_timestamp(s: &str) -> FileTime { }; match time::strptime(&ts, format) { - Ok(tm) => local_tm_to_filetime!(to_local!(tm)), + Ok(tm) => local_tm_to_filetime(to_local(tm)), Err(e) => panic!("Unable to parse timestamp\n{}", e), } } diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index cdf519dfe..918698e24 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tr" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "tr ~ (uutils) translate characters within input and display" @@ -18,7 +18,7 @@ path = "src/tr.rs" bit-set = "0.5.0" fnv = "1.0.5" getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/tr/src/expand.rs b/src/uu/tr/src/expand.rs index 3291d57ae..e71cf262c 100644 --- a/src/uu/tr/src/expand.rs +++ b/src/uu/tr/src/expand.rs @@ -14,17 +14,46 @@ use std::cmp::min; use std::iter::Peekable; use std::ops::RangeInclusive; +/// Parse a backslash escape sequence to the corresponding character. Assumes +/// the string starts from the character _after_ the `\` and is not empty. +/// +/// Returns a tuple containing the character and the number of characters +/// consumed from the input. The alphabetic escape sequences consume 1 +/// character; octal escape sequences consume 1 to 3 octal digits. #[inline] -fn unescape_char(c: char) -> char { - match c { - 'a' => 0x07u8 as char, - 'b' => 0x08u8 as char, - 'f' => 0x0cu8 as char, - 'v' => 0x0bu8 as char, - 'n' => '\n', - 'r' => '\r', - 't' => '\t', - _ => c, +fn parse_sequence(s: &str) -> (char, usize) { + let c = s.chars().next().expect("invalid escape: empty string"); + + if '0' <= c && c <= '7' { + let mut v = c.to_digit(8).unwrap(); + let mut consumed = 1; + let bits_per_digit = 3; + + for c in s.chars().skip(1).take(2) { + match c.to_digit(8) { + Some(c) => { + v = (v << bits_per_digit) | c; + consumed += 1; + } + None => break, + } + } + + (from_u32(v).expect("invalid octal escape"), consumed) + } else { + ( + match c { + 'a' => 0x07u8 as char, + 'b' => 0x08u8 as char, + 'f' => 0x0cu8 as char, + 'v' => 0x0bu8 as char, + 'n' => '\n', + 'r' => '\r', + 't' => '\t', + c => c, + }, + 1, + ) } } @@ -52,8 +81,9 @@ impl<'a> Iterator for Unescape<'a> { '\\' if self.string.len() > 1 => { // yes---it's \ and it's not the last char in a string // we know that \ is 1 byte long so we can index into the string safely - let c = self.string[1..].chars().next().unwrap(); - (Some(unescape_char(c)), 1 + c.len_utf8()) + let (c, consumed) = parse_sequence(&self.string[1..]); + + (Some(c), 1 + consumed) } c => (Some(c), c.len_utf8()), // not an escape char }; diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index 26dd321aa..a73bfddd5 100644 --- a/src/uu/true/Cargo.toml +++ b/src/uu/true/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_true" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "true ~ (uutils) do nothing and succeed" @@ -15,7 +15,7 @@ edition = "2018" path = "src/true.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index b0e5dc32b..4f770e666 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_truncate" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "truncate ~ (uutils) truncate (or extend) FILE to SIZE" @@ -16,7 +16,7 @@ path = "src/truncate.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index da44235c8..9cd5865b7 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -12,7 +12,6 @@ extern crate uucore; use clap::{App, Arg}; use std::fs::{metadata, File, OpenOptions}; -use std::io::Result; use std::path::Path; #[derive(Eq, PartialEq)] @@ -29,10 +28,12 @@ enum TruncateMode { static ABOUT: &str = "Shrink or extend the size of each file to the specified size."; static VERSION: &str = env!("CARGO_PKG_VERSION"); -static OPT_IO_BLOCKS: &str = "io-blocks"; -static OPT_NO_CREATE: &str = "no-create"; -static OPT_REFERENCE: &str = "reference"; -static OPT_SIZE: &str = "size"; +pub mod options { + pub static IO_BLOCKS: &str = "io-blocks"; + pub static NO_CREATE: &str = "no-create"; + pub static REFERENCE: &str = "reference"; + pub static SIZE: &str = "size"; +} static ARG_FILES: &str = "files"; @@ -72,26 +73,26 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .usage(&usage[..]) .after_help(&long_usage[..]) .arg( - Arg::with_name(OPT_IO_BLOCKS) + Arg::with_name(options::IO_BLOCKS) .short("o") - .long(OPT_IO_BLOCKS) + .long(options::IO_BLOCKS) .help("treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)") ) .arg( - Arg::with_name(OPT_NO_CREATE) + Arg::with_name(options::NO_CREATE) .short("c") - .long(OPT_NO_CREATE) + .long(options::NO_CREATE) .help("do not create files that do not exist") ) .arg( - Arg::with_name(OPT_REFERENCE) + Arg::with_name(options::REFERENCE) .short("r") - .long(OPT_REFERENCE) + .long(options::REFERENCE) .help("base the size of each file on the size of RFILE") .value_name("RFILE") ) .arg( - Arg::with_name(OPT_SIZE) + Arg::with_name(options::SIZE) .short("s") .long("size") .help("set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified") @@ -109,17 +110,14 @@ pub fn uumain(args: impl uucore::Args) -> i32 { show_error!("Missing an argument"); return 1; } else { - let io_blocks = matches.is_present(OPT_IO_BLOCKS); - let no_create = matches.is_present(OPT_NO_CREATE); - let reference = matches.value_of(OPT_REFERENCE).map(String::from); - let size = matches.value_of(OPT_SIZE).map(String::from); + let io_blocks = matches.is_present(options::IO_BLOCKS); + let no_create = matches.is_present(options::NO_CREATE); + let reference = matches.value_of(options::REFERENCE).map(String::from); + let size = matches.value_of(options::SIZE).map(String::from); if reference.is_none() && size.is_none() { crash!(1, "you must specify either --reference or --size"); } else { - match truncate(no_create, io_blocks, reference, size, files) { - Ok(()) => ( /* pass */ ), - Err(_) => return 1, - } + truncate(no_create, io_blocks, reference, size, files); } } @@ -132,7 +130,7 @@ fn truncate( reference: Option, size: Option, filenames: Vec, -) -> Result<()> { +) { let (refsize, mode) = match reference { Some(rfilename) => { let _ = match File::open(Path::new(&rfilename)) { @@ -191,7 +189,6 @@ fn truncate( Err(f) => crash!(1, "{}", f.to_string()), } } - Ok(()) } fn parse_size(size: &str) -> (u64, TruncateMode) { diff --git a/src/uu/tsort/Cargo.toml b/src/uu/tsort/Cargo.toml index 65e30b6c2..10672a9e0 100644 --- a/src/uu/tsort/Cargo.toml +++ b/src/uu/tsort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tsort" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "tsort ~ (uutils) topologically sort input (partially ordered) pairs" @@ -16,7 +16,7 @@ path = "src/tsort.rs" [dependencies] getopts = "0.2.18" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 2302c02cb..9912a3b9a 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tty" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "tty ~ (uutils) display the name of the terminal connected to standard input" @@ -17,7 +17,7 @@ path = "src/tty.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["fs"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index 5e54aff43..87754f45a 100644 --- a/src/uu/uname/Cargo.toml +++ b/src/uu/uname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uname" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "uname ~ (uutils) display system information" @@ -17,7 +17,7 @@ path = "src/uname.rs" [dependencies] clap = "2.33" platform-info = "0.1" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index b9b75e2a4..4586a084f 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -19,19 +19,17 @@ use platform_info::*; const VERSION: &str = env!("CARGO_PKG_VERSION"); const ABOUT: &str = "Print certain system information. With no OPTION, same as -s."; -const OPT_ALL: &str = "all"; -const OPT_KERNELNAME: &str = "kernel-name"; -const OPT_NODENAME: &str = "nodename"; -const OPT_KERNELVERSION: &str = "kernel-version"; -const OPT_KERNELRELEASE: &str = "kernel-release"; -const OPT_MACHINE: &str = "machine"; -const OPT_PROCESSOR: &str = "processor"; -const OPT_HWPLATFORM: &str = "hardware-platform"; - -//FIXME: unimplemented options -//const OPT_PROCESSOR: &'static str = "processor"; -//const OPT_HWPLATFORM: &'static str = "hardware-platform"; -const OPT_OS: &str = "operating-system"; +pub mod options { + pub static ALL: &str = "all"; + pub static KERNELNAME: &str = "kernel-name"; + pub static NODENAME: &str = "nodename"; + pub static KERNELVERSION: &str = "kernel-version"; + pub static KERNELRELEASE: &str = "kernel-release"; + pub static MACHINE: &str = "machine"; + pub static PROCESSOR: &str = "processor"; + pub static HWPLATFORM: &str = "hardware-platform"; + pub static OS: &str = "operating-system"; +} #[cfg(target_os = "linux")] const HOST_OS: &str = "GNU/Linux"; @@ -41,7 +39,7 @@ const HOST_OS: &str = "Windows NT"; const HOST_OS: &str = "FreeBSD"; #[cfg(target_os = "openbsd")] const HOST_OS: &str = "OpenBSD"; -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] const HOST_OS: &str = "Darwin"; #[cfg(target_os = "fuchsia")] const HOST_OS: &str = "Fuchsia"; @@ -54,58 +52,58 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .version(VERSION) .about(ABOUT) .usage(&usage[..]) - .arg(Arg::with_name(OPT_ALL) + .arg(Arg::with_name(options::ALL) .short("a") - .long(OPT_ALL) + .long(options::ALL) .help("Behave as though all of the options -mnrsv were specified.")) - .arg(Arg::with_name(OPT_KERNELNAME) + .arg(Arg::with_name(options::KERNELNAME) .short("s") - .long(OPT_KERNELNAME) + .long(options::KERNELNAME) .alias("sysname") // Obsolescent option in GNU uname .help("print the kernel name.")) - .arg(Arg::with_name(OPT_NODENAME) + .arg(Arg::with_name(options::NODENAME) .short("n") - .long(OPT_NODENAME) + .long(options::NODENAME) .help("print the nodename (the nodename may be a name that the system is known by to a communications network).")) - .arg(Arg::with_name(OPT_KERNELRELEASE) + .arg(Arg::with_name(options::KERNELRELEASE) .short("r") - .long(OPT_KERNELRELEASE) + .long(options::KERNELRELEASE) .alias("release") // Obsolescent option in GNU uname .help("print the operating system release.")) - .arg(Arg::with_name(OPT_KERNELVERSION) + .arg(Arg::with_name(options::KERNELVERSION) .short("v") - .long(OPT_KERNELVERSION) + .long(options::KERNELVERSION) .help("print the operating system version.")) - .arg(Arg::with_name(OPT_HWPLATFORM) + .arg(Arg::with_name(options::HWPLATFORM) .short("i") - .long(OPT_HWPLATFORM) + .long(options::HWPLATFORM) .help("print the hardware platform (non-portable)")) - .arg(Arg::with_name(OPT_MACHINE) + .arg(Arg::with_name(options::MACHINE) .short("m") - .long(OPT_MACHINE) + .long(options::MACHINE) .help("print the machine hardware name.")) - .arg(Arg::with_name(OPT_PROCESSOR) + .arg(Arg::with_name(options::PROCESSOR) .short("p") - .long(OPT_PROCESSOR) + .long(options::PROCESSOR) .help("print the processor type (non-portable)")) - .arg(Arg::with_name(OPT_OS) + .arg(Arg::with_name(options::OS) .short("o") - .long(OPT_OS) + .long(options::OS) .help("print the operating system name.")) .get_matches_from(args); let uname = return_if_err!(1, PlatformInfo::new()); let mut output = String::new(); - let all = matches.is_present(OPT_ALL); - let kernelname = matches.is_present(OPT_KERNELNAME); - let nodename = matches.is_present(OPT_NODENAME); - let kernelrelease = matches.is_present(OPT_KERNELRELEASE); - let kernelversion = matches.is_present(OPT_KERNELVERSION); - let machine = matches.is_present(OPT_MACHINE); - let processor = matches.is_present(OPT_PROCESSOR); - let hwplatform = matches.is_present(OPT_HWPLATFORM); - let os = matches.is_present(OPT_OS); + let all = matches.is_present(options::ALL); + let kernelname = matches.is_present(options::KERNELNAME); + let nodename = matches.is_present(options::NODENAME); + let kernelrelease = matches.is_present(options::KERNELRELEASE); + let kernelversion = matches.is_present(options::KERNELVERSION); + let machine = matches.is_present(options::MACHINE); + let processor = matches.is_present(options::PROCESSOR); + let hwplatform = matches.is_present(options::HWPLATFORM); + let os = matches.is_present(options::OS); let none = !(all || kernelname diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index 218b100b7..ec6967e21 100644 --- a/src/uu/unexpand/Cargo.toml +++ b/src/uu/unexpand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unexpand" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "unexpand ~ (uutils) convert input spaces to tabs" @@ -17,7 +17,7 @@ path = "src/unexpand.rs" [dependencies] getopts = "0.2.18" unicode-width = "0.1.5" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index 924e2f93c..d3cf4309d 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uniq" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "uniq ~ (uutils) filter identical adjacent lines from input" @@ -16,7 +16,7 @@ path = "src/uniq.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 9261dba9b..a1809f0f0 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -10,21 +10,23 @@ extern crate uucore; use clap::{App, Arg, ArgMatches}; use std::fs::File; -use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write}; +use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Result, Write}; use std::path::Path; use std::str::FromStr; static ABOUT: &str = "Report or omit repeated lines."; static VERSION: &str = env!("CARGO_PKG_VERSION"); -static OPT_ALL_REPEATED: &str = "all-repeated"; -static OPT_CHECK_CHARS: &str = "check-chars"; -static OPT_COUNT: &str = "count"; -static OPT_IGNORE_CASE: &str = "ignore-case"; -static OPT_REPEATED: &str = "repeated"; -static OPT_SKIP_FIELDS: &str = "skip-fields"; -static OPT_SKIP_CHARS: &str = "skip-chars"; -static OPT_UNIQUE: &str = "unique"; -static OPT_ZERO_TERMINATED: &str = "zero-terminated"; +pub mod options { + pub static ALL_REPEATED: &str = "all-repeated"; + pub static CHECK_CHARS: &str = "check-chars"; + pub static COUNT: &str = "count"; + pub static IGNORE_CASE: &str = "ignore-case"; + pub static REPEATED: &str = "repeated"; + pub static SKIP_FIELDS: &str = "skip-fields"; + pub static SKIP_CHARS: &str = "skip-chars"; + pub static UNIQUE: &str = "unique"; + pub static ZERO_TERMINATED: &str = "zero-terminated"; +} static ARG_FILES: &str = "files"; @@ -59,8 +61,7 @@ impl Uniq { let delimiters = &self.delimiters; let line_terminator = self.get_line_terminator(); - for io_line in reader.split(line_terminator) { - let line = String::from_utf8(crash_if_err!(1, io_line)).unwrap(); + for line in reader.split(line_terminator).map(get_line_string) { if !lines.is_empty() && self.cmp_keys(&lines[0], &line) { let print_delimiter = delimiters == &Delimiters::Prepend || (delimiters == &Delimiters::Separate && first_line_printed); @@ -78,22 +79,19 @@ impl Uniq { fn skip_fields<'a>(&self, line: &'a str) -> &'a str { if let Some(skip_fields) = self.skip_fields { - if line.split_whitespace().count() > skip_fields { - let mut field = 0; - let mut i = 0; - while field < skip_fields && i < line.len() { - while i < line.len() && line.chars().nth(i).unwrap().is_whitespace() { - i += 1; - } - while i < line.len() && !line.chars().nth(i).unwrap().is_whitespace() { - i += 1; - } - field += 1; + let mut i = 0; + let mut char_indices = line.char_indices(); + for _ in 0..skip_fields { + if char_indices.find(|(_, c)| !c.is_whitespace()) == None { + return ""; + } + match char_indices.find(|(_, c)| c.is_whitespace()) { + None => return "", + + Some((next_field_i, _)) => i = next_field_i, } - &line[i..] - } else { - "" } + &line[i..] } else { line } @@ -129,10 +127,7 @@ impl Uniq { // fast path: avoid skipping if self.ignore_case && slice_start == 0 && slice_stop == len { - return closure(&mut fields_to_check.chars().map(|c| match c { - 'a'..='z' => ((c as u8) - 32) as char, - _ => c, - })); + return closure(&mut fields_to_check.chars().flat_map(|c| c.to_uppercase())); } // fast path: we can avoid mapping chars to upper-case, if we don't want to ignore the case @@ -145,10 +140,7 @@ impl Uniq { .chars() .skip(slice_start) .take(slice_stop) - .map(|c| match c { - 'a'..='z' => ((c as u8) - 32) as char, - _ => c, - }), + .flat_map(|c| c.to_uppercase()), ) } else { closure(&mut fields_to_check.chars()) @@ -203,6 +195,11 @@ impl Uniq { } } +fn get_line_string(io_line: Result>) -> String { + let line_bytes = crash_if_err!(1, io_line); + crash_if_err!(1, String::from_utf8(line_bytes)) +} + fn opt_parsed(opt_name: &str, matches: &ArgMatches) -> Option { matches.value_of(opt_name).map(|arg_str| { let opt_val: Option = arg_str.parse().ok(); @@ -233,63 +230,63 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .usage(&usage[..]) .after_help(&long_usage[..]) .arg( - Arg::with_name(OPT_ALL_REPEATED) + Arg::with_name(options::ALL_REPEATED) .short("D") - .long(OPT_ALL_REPEATED) + .long(options::ALL_REPEATED) .possible_values(&["none", "prepend", "separate"]) .help("print all duplicate lines. Delimiting is done with blank lines") .value_name("delimit-method") .default_value("none"), ) .arg( - Arg::with_name(OPT_CHECK_CHARS) + Arg::with_name(options::CHECK_CHARS) .short("w") - .long(OPT_CHECK_CHARS) + .long(options::CHECK_CHARS) .help("compare no more than N characters in lines") .value_name("N"), ) .arg( - Arg::with_name(OPT_COUNT) + Arg::with_name(options::COUNT) .short("c") - .long(OPT_COUNT) + .long(options::COUNT) .help("prefix lines by the number of occurrences"), ) .arg( - Arg::with_name(OPT_IGNORE_CASE) + Arg::with_name(options::IGNORE_CASE) .short("i") - .long(OPT_IGNORE_CASE) + .long(options::IGNORE_CASE) .help("ignore differences in case when comparing"), ) .arg( - Arg::with_name(OPT_REPEATED) + Arg::with_name(options::REPEATED) .short("d") - .long(OPT_REPEATED) + .long(options::REPEATED) .help("only print duplicate lines"), ) .arg( - Arg::with_name(OPT_SKIP_CHARS) + Arg::with_name(options::SKIP_CHARS) .short("s") - .long(OPT_SKIP_CHARS) + .long(options::SKIP_CHARS) .help("avoid comparing the first N characters") .value_name("N"), ) .arg( - Arg::with_name(OPT_SKIP_FIELDS) + Arg::with_name(options::SKIP_FIELDS) .short("f") - .long(OPT_SKIP_FIELDS) + .long(options::SKIP_FIELDS) .help("avoid comparing the first N fields") .value_name("N"), ) .arg( - Arg::with_name(OPT_UNIQUE) + Arg::with_name(options::UNIQUE) .short("u") - .long(OPT_UNIQUE) + .long(options::UNIQUE) .help("only print unique lines"), ) .arg( - Arg::with_name(OPT_ZERO_TERMINATED) + Arg::with_name(options::ZERO_TERMINATED) .short("z") - .long(OPT_ZERO_TERMINATED) + .long(options::ZERO_TERMINATED) .help("end lines with 0 byte, not newline"), ) .arg( @@ -316,11 +313,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 { }; let uniq = Uniq { - repeats_only: matches.is_present(OPT_REPEATED) - || matches.occurrences_of(OPT_ALL_REPEATED) > 0, - uniques_only: matches.is_present(OPT_UNIQUE), - all_repeated: matches.occurrences_of(OPT_ALL_REPEATED) > 0, - delimiters: match matches.value_of(OPT_ALL_REPEATED).map(String::from) { + repeats_only: matches.is_present(options::REPEATED) + || matches.occurrences_of(options::ALL_REPEATED) > 0, + uniques_only: matches.is_present(options::UNIQUE), + all_repeated: matches.occurrences_of(options::ALL_REPEATED) > 0, + delimiters: match matches.value_of(options::ALL_REPEATED).map(String::from) { Some(ref opt_arg) if opt_arg != "none" => match &(*opt_arg.as_str()) { "prepend" => Delimiters::Prepend, "separate" => Delimiters::Separate, @@ -328,12 +325,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 { }, _ => Delimiters::None, }, - show_counts: matches.is_present(OPT_COUNT), - skip_fields: opt_parsed(OPT_SKIP_FIELDS, &matches), - slice_start: opt_parsed(OPT_SKIP_CHARS, &matches), - slice_stop: opt_parsed(OPT_CHECK_CHARS, &matches), - ignore_case: matches.is_present(OPT_IGNORE_CASE), - zero_terminated: matches.is_present(OPT_ZERO_TERMINATED), + show_counts: matches.is_present(options::COUNT), + skip_fields: opt_parsed(options::SKIP_FIELDS, &matches), + slice_start: opt_parsed(options::SKIP_CHARS, &matches), + slice_stop: opt_parsed(options::CHECK_CHARS, &matches), + ignore_case: matches.is_present(options::IGNORE_CASE), + zero_terminated: matches.is_present(options::ZERO_TERMINATED), }; uniq.print_uniq( &mut open_input_file(in_file_name), diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index 1326dcc96..68edec54d 100644 --- a/src/uu/unlink/Cargo.toml +++ b/src/uu/unlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unlink" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "unlink ~ (uutils) remove a (file system) link to FILE" @@ -17,7 +17,7 @@ path = "src/unlink.rs" [dependencies] getopts = "0.2.18" libc = "0.2.42" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index ac32da353..d66acc77f 100644 --- a/src/uu/uptime/Cargo.toml +++ b/src/uu/uptime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uptime" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "uptime ~ (uutils) display dynamic system information" @@ -17,7 +17,7 @@ path = "src/uptime.rs" [dependencies] chrono = "0.4" clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["libc", "utmpx"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["libc", "utmpx"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index 4ea90e242..670d7845b 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -21,7 +21,9 @@ static VERSION: &str = env!("CARGO_PKG_VERSION"); static ABOUT: &str = "Display the current time, the length of time the system has been up,\n\ the number of users on the system, and the average number of jobs\n\ in the run queue over the last 1, 5 and 15 minutes."; -static OPT_SINCE: &str = "since"; +pub mod options { + pub static SINCE: &str = "since"; +} #[cfg(unix)] use uucore::libc::getloadavg; @@ -42,9 +44,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .arg( - Arg::with_name(OPT_SINCE) + Arg::with_name(options::SINCE) .short("s") - .long(OPT_SINCE) + .long(options::SINCE) .help("system up since"), ) .get_matches_from(args); @@ -56,7 +58,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { 1 } else { - if matches.is_present(OPT_SINCE) { + if matches.is_present(options::SINCE) { let initial_date = Local.timestamp(Utc::now().timestamp() - uptime, 0); println!("{}", initial_date.format("%Y-%m-%d %H:%M:%S")); return 0; diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index d5f331755..ed6f110b6 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_users" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "users ~ (uutils) display names of currently logged-in users" @@ -16,7 +16,7 @@ path = "src/users.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["utmpx"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["utmpx"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index c50989d32..894ac44dd 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_wc" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "wc ~ (uutils) display newline, word, and byte counts for input" @@ -16,7 +16,7 @@ path = "src/wc.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore" } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 68e955f81..972802f81 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -29,11 +29,11 @@ struct Settings { impl Settings { fn new(matches: &ArgMatches) -> Settings { let settings = Settings { - show_bytes: matches.is_present(OPT_BYTES), - show_chars: matches.is_present(OPT_CHAR), - show_lines: matches.is_present(OPT_LINES), - show_words: matches.is_present(OPT_WORDS), - show_max_line_length: matches.is_present(OPT_MAX_LINE_LENGTH), + show_bytes: matches.is_present(options::BYTES), + show_chars: matches.is_present(options::CHAR), + show_lines: matches.is_present(options::LINES), + show_words: matches.is_present(options::WORDS), + show_max_line_length: matches.is_present(options::MAX_LINE_LENGTH), }; if settings.show_bytes @@ -68,11 +68,13 @@ static ABOUT: &str = "Display newline, word, and byte counts for each FILE, and more than one FILE is specified."; static VERSION: &str = env!("CARGO_PKG_VERSION"); -static OPT_BYTES: &str = "bytes"; -static OPT_CHAR: &str = "chars"; -static OPT_LINES: &str = "lines"; -static OPT_MAX_LINE_LENGTH: &str = "max-line-length"; -static OPT_WORDS: &str = "words"; +pub mod options { + pub static BYTES: &str = "bytes"; + pub static CHAR: &str = "chars"; + pub static LINES: &str = "lines"; + pub static MAX_LINE_LENGTH: &str = "max-line-length"; + pub static WORDS: &str = "words"; +} static ARG_FILES: &str = "files"; @@ -92,33 +94,33 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .about(ABOUT) .usage(&usage[..]) .arg( - Arg::with_name(OPT_BYTES) + Arg::with_name(options::BYTES) .short("c") - .long(OPT_BYTES) + .long(options::BYTES) .help("print the byte counts"), ) .arg( - Arg::with_name(OPT_CHAR) + Arg::with_name(options::CHAR) .short("m") - .long(OPT_CHAR) + .long(options::CHAR) .help("print the character counts"), ) .arg( - Arg::with_name(OPT_LINES) + Arg::with_name(options::LINES) .short("l") - .long(OPT_LINES) + .long(options::LINES) .help("print the newline counts"), ) .arg( - Arg::with_name(OPT_MAX_LINE_LENGTH) + Arg::with_name(options::MAX_LINE_LENGTH) .short("L") - .long(OPT_MAX_LINE_LENGTH) + .long(options::MAX_LINE_LENGTH) .help("print the length of the longest line"), ) .arg( - Arg::with_name(OPT_WORDS) + Arg::with_name(options::WORDS) .short("w") - .long(OPT_WORDS) + .long(options::WORDS) .help("print the word counts"), ) .arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index 2fdc64255..fce0178aa 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_who" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "who ~ (uutils) display information about currently logged-in users" @@ -15,7 +15,7 @@ edition = "2018" path = "src/who.rs" [dependencies] -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["utmpx"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["utmpx"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [[bin]] diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index b028be0a0..8c7ff3211 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -60,12 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { "count", "all login names and number of users logged on", ); - #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "linux", - target_os = "android" - ))] + #[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))] opts.optflag("r", "runlevel", "print current runlevel"); opts.optflag("s", "short", "print only name, line, and time (default)"); opts.optflag("t", "time", "print last system clock change"); @@ -305,12 +300,7 @@ impl Who { #[allow(unused_assignments)] let mut res = false; - #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "linux", - target_os = "android" - ))] + #[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))] { res = record == utmpx::RUN_LVL; } diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index ee2ac9031..a3158f62a 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_whoami" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "whoami ~ (uutils) display user name of current effective user ID" @@ -16,7 +16,7 @@ path = "src/whoami.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["entries", "wide"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries", "wide"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "windows")'.dependencies] diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index c4fc09acf..729ce693a 100644 --- a/src/uu/yes/Cargo.toml +++ b/src/uu/yes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_yes" -version = "0.0.3" +version = "0.0.4" authors = ["uutils developers"] license = "MIT" description = "yes ~ (uutils) repeatedly display a line with STRING (or 'y')" @@ -16,7 +16,7 @@ path = "src/yes.rs" [dependencies] clap = "2.33" -uucore = { version=">=0.0.6", package="uucore", path="../../uucore", features=["zero-copy"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["zero-copy"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [features] diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index dd7d9e69d..a5fbe4c79 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uucore" -version = "0.0.6" +version = "0.0.7" authors = ["uutils developers"] license = "MIT" description = "uutils ~ 'core' uutils code library (cross-platform)" @@ -23,7 +23,7 @@ wild = "2.0.4" thiserror = { version="1.0", optional=true } lazy_static = { version="1.3", optional=true } nix = { version="<= 0.13", optional=true } -platform-info = { version="<= 0.0.1", optional=true } +platform-info = { version="<= 0.1", optional=true } time = { version="<= 0.1.42", optional=true } # * "problem" dependencies (pinned) data-encoding = { version="~2.1", optional=true } ## data-encoding: require v2.1; but v2.2.0 breaks the build for MinSRV v1.31.0 diff --git a/src/uucore/src/lib/features/entries.rs b/src/uucore/src/lib/features/entries.rs index a921af2d0..d2dce2461 100644 --- a/src/uucore/src/lib/features/entries.rs +++ b/src/uucore/src/lib/features/entries.rs @@ -34,7 +34,7 @@ //! assert!(entries::Group::locate(root_group).is_ok()); //! ``` -#[cfg(any(target_os = "freebsd", target_os = "macos"))] +#[cfg(any(target_os = "freebsd", target_vendor = "apple"))] use libc::time_t; use libc::{c_char, c_int, gid_t, uid_t}; use libc::{getgrgid, getgrnam, getgroups, getpwnam, getpwuid, group, passwd}; @@ -119,19 +119,19 @@ impl Passwd { } /// AKA passwd.pw_class - #[cfg(any(target_os = "freebsd", target_os = "macos"))] + #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] pub fn user_access_class(&self) -> Cow { cstr2cow!(self.inner.pw_class) } /// AKA passwd.pw_change - #[cfg(any(target_os = "freebsd", target_os = "macos"))] + #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] pub fn passwd_change_time(&self) -> time_t { self.inner.pw_change } /// AKA passwd.pw_expire - #[cfg(any(target_os = "freebsd", target_os = "macos"))] + #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] pub fn expiration(&self) -> time_t { self.inner.pw_expire } diff --git a/src/uucore/src/lib/features/signals.rs b/src/uucore/src/lib/features/signals.rs index 294669eab..d22fa1791 100644 --- a/src/uucore/src/lib/features/signals.rs +++ b/src/uucore/src/lib/features/signals.rs @@ -197,7 +197,7 @@ No Name Default Action Description */ -#[cfg(any(target_os = "macos", target_os = "freebsd"))] +#[cfg(any(target_vendor = "apple", target_os = "freebsd"))] pub static ALL_SIGNALS: [Signal<'static>; 31] = [ Signal { name: "HUP", diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 31cd3b72c..0308d8a5e 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -47,7 +47,7 @@ use libc::utmpx; pub use libc::endutxent; pub use libc::getutxent; pub use libc::setutxent; -#[cfg(any(target_os = "macos", target_os = "linux"))] +#[cfg(any(target_vendor = "apple", target_os = "linux"))] pub use libc::utmpxname; #[cfg(target_os = "freebsd")] pub unsafe extern "C" fn utmpxname(_file: *const libc::c_char) -> libc::c_int { @@ -85,7 +85,7 @@ mod ut { pub use libc::USER_PROCESS; } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] mod ut { pub static DEFAULT_FILE: &str = "/var/run/utmpx"; diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 768843409..324095b6a 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -27,6 +27,7 @@ mod mods; // core cross-platform modules // * cross-platform modules pub use crate::mods::coreopts; pub use crate::mods::panic; +pub use crate::mods::ranges; // * feature-gated modules #[cfg(feature = "encoding")] diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index 0becc71bd..c73909dcc 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -2,3 +2,4 @@ pub mod coreopts; pub mod panic; +pub mod ranges; diff --git a/src/uu/cut/src/ranges.rs b/src/uucore/src/lib/mods/ranges.rs similarity index 83% rename from src/uu/cut/src/ranges.rs rename to src/uucore/src/lib/mods/ranges.rs index 74fec08e6..d4a6bf601 100644 --- a/src/uu/cut/src/ranges.rs +++ b/src/uucore/src/lib/mods/ranges.rs @@ -144,3 +144,31 @@ pub fn complement(ranges: &[Range]) -> Vec { complements } + +/// Test if at least one of the given Ranges contain the supplied value. +/// +/// Examples: +/// +/// ``` +/// let ranges = uucore::ranges::Range::from_list("11,2,6-8").unwrap(); +/// +/// assert!(!uucore::ranges::contain(&ranges, 0)); +/// assert!(!uucore::ranges::contain(&ranges, 1)); +/// assert!(!uucore::ranges::contain(&ranges, 5)); +/// assert!(!uucore::ranges::contain(&ranges, 10)); +/// +/// assert!(uucore::ranges::contain(&ranges, 2)); +/// assert!(uucore::ranges::contain(&ranges, 6)); +/// assert!(uucore::ranges::contain(&ranges, 7)); +/// assert!(uucore::ranges::contain(&ranges, 8)); +/// assert!(uucore::ranges::contain(&ranges, 11)); +/// ``` +pub fn contain(ranges: &[Range], n: usize) -> bool { + for range in ranges { + if n >= range.low && n <= range.high { + return true; + } + } + + false +} diff --git a/tests/by-util/test_cat.rs b/tests/by-util/test_cat.rs index a3e321139..b194eb9b0 100644 --- a/tests/by-util/test_cat.rs +++ b/tests/by-util/test_cat.rs @@ -10,16 +10,16 @@ fn test_output_multi_files_print_all_chars() { .succeeds() .stdout_only( " 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n \ - 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n \ - 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ \ - !\"#$%&\'()*+,-./0123456789:;\ - <=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^\ - BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^V\ - M-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- \ - M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:\ - M-;M-M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-U\ - M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\ - pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?", + 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n \ + 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ \ + !\"#$%&\'()*+,-./0123456789:;\ + <=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^\ + BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^V\ + M-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- \ + M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:\ + M-;M-M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-U\ + M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\ + pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?", ); } @@ -30,7 +30,7 @@ fn test_numbered_lines_no_trailing_newline() { .succeeds() .stdout_only( " 1\ttext without a trailing newlineabcde\n 2\tfghij\n \ - 3\tklmno\n 4\tpqrst\n 5\tuvwxyz\n", + 3\tklmno\n 4\tpqrst\n 5\tuvwxyz\n", ); } diff --git a/tests/by-util/test_chgrp.rs b/tests/by-util/test_chgrp.rs index d5afaf3a7..613f52fd2 100644 --- a/tests/by-util/test_chgrp.rs +++ b/tests/by-util/test_chgrp.rs @@ -115,7 +115,7 @@ fn test_reference() { } #[test] -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn test_reference() { new_ucmd!() .arg("-v") diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index ccab0134b..b96bd4e29 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -479,6 +479,91 @@ fn test_cp_no_deref() { assert_eq!(at.read(&path_to_check), "Hello, World!\n"); } +#[test] +fn test_cp_strip_trailing_slashes() { + let (at, mut ucmd) = at_and_ucmd!(); + + //using --strip-trailing-slashes option + let result = ucmd + .arg("--strip-trailing-slashes") + .arg(format!("{}/", TEST_HELLO_WORLD_SOURCE)) + .arg(TEST_HELLO_WORLD_DEST) + .run(); + + // Check that the exit code represents a successful copy. + assert!(result.success); + + // Check the content of the destination file that was copied. + assert_eq!(at.read(TEST_HELLO_WORLD_DEST), "Hello, World!\n"); +} + +#[test] +fn test_cp_parents() { + let (at, mut ucmd) = at_and_ucmd!(); + + let result = ucmd + .arg("--parents") + .arg(TEST_COPY_FROM_FOLDER_FILE) + .arg(TEST_COPY_TO_FOLDER) + .run(); + + assert!(result.success); + // Check the content of the destination file that was copied. + assert_eq!( + at.read(&format!( + "{}/{}", + TEST_COPY_TO_FOLDER, TEST_COPY_FROM_FOLDER_FILE + )), + "Hello, World!\n" + ); +} + +#[test] +fn test_cp_parents_multiple_files() { + let (at, mut ucmd) = at_and_ucmd!(); + + let result = ucmd + .arg("--parents") + .arg(TEST_COPY_FROM_FOLDER_FILE) + .arg(TEST_HOW_ARE_YOU_SOURCE) + .arg(TEST_COPY_TO_FOLDER) + .run(); + + assert!(result.success); + assert_eq!( + at.read(&format!( + "{}/{}", + TEST_COPY_TO_FOLDER, TEST_COPY_FROM_FOLDER_FILE + )), + "Hello, World!\n" + ); + assert_eq!( + at.read(&format!( + "{}/{}", + TEST_COPY_TO_FOLDER, TEST_HOW_ARE_YOU_SOURCE + )), + "How are you?\n" + ); +} + +#[test] +fn test_cp_parents_dest_not_directory() { + let (_, mut ucmd) = at_and_ucmd!(); + + let result = ucmd + .arg("--parents") + .arg(TEST_COPY_FROM_FOLDER_FILE) + .arg(TEST_HELLO_WORLD_DEST) + .run(); + println!("{:?}", result); + + // Check that we did not succeed in copying. + assert!(!result.success); + assert!(result + .stderr + .contains("with --parents, the destination must be a directory")); +} + #[test] // For now, disable the test on Windows. Symlinks aren't well support on Windows. // It works on Unix for now and it works locally when run from a powershell diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index c9704a658..a79f820fb 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -12,7 +12,7 @@ fn test_du_basics() { assert!(result.success); assert_eq!(result.stderr, ""); } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn _du_basics(s: String) { let answer = "32\t./subdir 8\t./subdir/deeper @@ -21,7 +21,7 @@ fn _du_basics(s: String) { "; assert_eq!(s, answer); } -#[cfg(not(target_os = "macos"))] +#[cfg(not(target_vendor = "apple"))] fn _du_basics(s: String) { let answer = "28\t./subdir 8\t./subdir/deeper @@ -41,11 +41,11 @@ fn test_du_basics_subdir() { _du_basics_subdir(result.stdout); } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn _du_basics_subdir(s: String) { assert_eq!(s, "4\tsubdir/deeper\n"); } -#[cfg(not(target_os = "macos"))] +#[cfg(not(target_vendor = "apple"))] fn _du_basics_subdir(s: String) { // MS-WSL linux has altered expected output if !is_wsl() { @@ -80,12 +80,12 @@ fn test_du_soft_link() { _du_soft_link(result.stdout); } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn _du_soft_link(s: String) { // 'macos' host variants may have `du` output variation for soft links assert!((s == "12\tsubdir/links\n") || (s == "16\tsubdir/links\n")); } -#[cfg(not(target_os = "macos"))] +#[cfg(not(target_vendor = "apple"))] fn _du_soft_link(s: String) { // MS-WSL linux has altered expected output if !is_wsl() { @@ -109,11 +109,11 @@ fn test_du_hard_link() { _du_hard_link(result.stdout); } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn _du_hard_link(s: String) { assert_eq!(s, "12\tsubdir/links\n") } -#[cfg(not(target_os = "macos"))] +#[cfg(not(target_vendor = "apple"))] fn _du_hard_link(s: String) { // MS-WSL linux has altered expected output if !is_wsl() { @@ -133,11 +133,11 @@ fn test_du_d_flag() { _du_d_flag(result.stdout); } -#[cfg(target_os = "macos")] +#[cfg(target_vendor = "apple")] fn _du_d_flag(s: String) { assert_eq!(s, "16\t./subdir\n20\t./\n"); } -#[cfg(not(target_os = "macos"))] +#[cfg(not(target_vendor = "apple"))] fn _du_d_flag(s: String) { // MS-WSL linux has altered expected output if !is_wsl() { diff --git a/tests/by-util/test_expand.rs b/tests/by-util/test_expand.rs index 121ccccec..801bf9d98 100644 --- a/tests/by-util/test_expand.rs +++ b/tests/by-util/test_expand.rs @@ -46,3 +46,13 @@ fn test_with_space() { assert!(result.success); assert!(result.stdout.contains(" return")); } + +#[test] +fn test_with_multiple_files() { + let (_, mut ucmd) = at_and_ucmd!(); + + let result = ucmd.arg("with-spaces.txt").arg("with-tab.txt").run(); + assert!(result.success); + assert!(result.stdout.contains(" return")); + assert!(result.stdout.contains(" ")); +} diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 4324290cb..eec82b51f 100644 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -86,6 +86,14 @@ fn test_verbose() { .stdout_is_fixture("lorem_ipsum_verbose.expected"); } +#[test] +fn test_zero_terminated() { + new_ucmd!() + .args(&["-z", "zero_terminated.txt"]) + .run() + .stdout_is_fixture("zero_terminated.expected"); +} + #[test] #[ignore] fn test_spams_newline() { diff --git a/tests/by-util/test_hostname.rs b/tests/by-util/test_hostname.rs index a526ddd88..804d47642 100644 --- a/tests/by-util/test_hostname.rs +++ b/tests/by-util/test_hostname.rs @@ -11,7 +11,7 @@ fn test_hostname() { } // FixME: fails for "MacOS" -#[cfg(not(target_os = "macos"))] +#[cfg(not(target_vendor = "apple"))] #[test] fn test_hostname_ip() { let result = new_ucmd!().arg("-i").run(); diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index a04c0ddfc..7b3706f9e 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -309,6 +309,31 @@ fn test_install_target_new_file_failing_nonexistent_parent() { assert!(err.contains("not a directory")) } +#[test] +fn test_install_preserve_timestamps() { + let (at, mut ucmd) = at_and_ucmd!(); + let file1 = "test_install_target_dir_file_a1"; + let file2 = "test_install_target_dir_file_a2"; + at.touch(file1); + + ucmd.arg(file1).arg(file2).arg("-p").succeeds().no_stderr(); + + assert!(at.file_exists(file1)); + assert!(at.file_exists(file2)); + + let file1_metadata = at.metadata(file1); + let file2_metadata = at.metadata(file2); + + assert_eq!( + file1_metadata.accessed().ok(), + file2_metadata.accessed().ok() + ); + assert_eq!( + file1_metadata.modified().ok(), + file2_metadata.modified().ok() + ); +} + // These two tests are failing but should work #[test] fn test_install_copy_file() { diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 4dc4168de..a1c3d7569 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -285,7 +285,7 @@ fn test_ls_ls_color() { scene.ucmd().arg("--color=never").arg("z").succeeds(); } -#[cfg(not(target_os = "macos"))] // Truncate not available on mac +#[cfg(not(any(target_vendor = "apple", target_os = "windows")))] // Truncate not available on mac or win #[test] fn test_ls_human() { let scene = TestScenario::new(util_name!()); diff --git a/tests/by-util/test_nice.rs b/tests/by-util/test_nice.rs index 651491045..7e704fc00 100644 --- a/tests/by-util/test_nice.rs +++ b/tests/by-util/test_nice.rs @@ -1 +1,58 @@ -// ToDO: add tests +use crate::common::util::*; + +#[test] +fn test_get_current_niceness() { + // NOTE: this assumes the test suite is being run with a default niceness + // of 0, which may not necessarily be true + new_ucmd!().run().stdout_is("0\n"); +} + +#[test] +fn test_negative_adjustment() { + // This assumes the test suite is run as a normal (non-root) user, and as + // such attempting to set a negative niceness value will be rejected by + // the OS. If it gets denied, then we know a negative value was parsed + // correctly. + + let res = new_ucmd!().args(&["-n", "-1", "true"]).run(); + assert!(res + .stderr + .starts_with("nice: warning: setpriority: Permission denied")); +} + +#[test] +fn test_adjustment_with_no_command_should_error() { + new_ucmd!() + .args(&["-n", "19"]) + .run() + .stderr_is("nice: error: A command must be given with an adjustment.\nTry \"nice --help\" for more information.\n"); +} + +#[test] +fn test_command_with_no_adjustment() { + new_ucmd!().args(&["echo", "a"]).run().stdout_is("a\n"); +} + +#[test] +fn test_command_with_no_args() { + new_ucmd!() + .args(&["-n", "19", "echo"]) + .run() + .stdout_is("\n"); +} + +#[test] +fn test_command_with_args() { + new_ucmd!() + .args(&["-n", "19", "echo", "a", "b", "c"]) + .run() + .stdout_is("a b c\n"); +} + +#[test] +fn test_command_where_command_takes_n_flag() { + new_ucmd!() + .args(&["-n", "19", "echo", "-n", "a"]) + .run() + .stdout_is("a"); +} diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index fca73c37b..3ca039d19 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -23,8 +23,8 @@ fn test_padding_without_overflow() { .run() .stdout_is( "000001xL1\n001001xL2\n002001xL3\n003001xL4\n004001xL5\n005001xL6\n006001xL7\n0070\ - 01xL8\n008001xL9\n009001xL10\n010001xL11\n011001xL12\n012001xL13\n013001xL14\n014\ - 001xL15\n", + 01xL8\n008001xL9\n009001xL10\n010001xL11\n011001xL12\n012001xL13\n013001xL14\n014\ + 001xL15\n", ); } @@ -35,7 +35,7 @@ fn test_padding_with_overflow() { .run() .stdout_is( "0001xL1\n1001xL2\n2001xL3\n3001xL4\n4001xL5\n5001xL6\n6001xL7\n7001xL8\n8001xL9\n\ - 9001xL10\n10001xL11\n11001xL12\n12001xL13\n13001xL14\n14001xL15\n", + 9001xL10\n10001xL11\n11001xL12\n12001xL13\n13001xL14\n14001xL15\n", ); } @@ -45,15 +45,15 @@ fn test_sections_and_styles() { ( "section.txt", "\nHEADER1\nHEADER2\n\n1 |BODY1\n2 \ - |BODY2\n\nFOOTER1\nFOOTER2\n\nNEXTHEADER1\nNEXTHEADER2\n\n1 \ - |NEXTBODY1\n2 |NEXTBODY2\n\nNEXTFOOTER1\nNEXTFOOTER2\n", + |BODY2\n\nFOOTER1\nFOOTER2\n\nNEXTHEADER1\nNEXTHEADER2\n\n1 \ + |NEXTBODY1\n2 |NEXTBODY2\n\nNEXTFOOTER1\nNEXTFOOTER2\n", ), ( "joinblanklines.txt", "1 |Nonempty\n2 |Nonempty\n3 |Followed by 10x empty\n\n\n\n\n4 \ - |\n\n\n\n\n5 |\n6 |Followed by 5x empty\n\n\n\n\n7 |\n8 \ - |Followed by 4x empty\n\n\n\n\n9 |Nonempty\n10 |Nonempty\n11 \ - |Nonempty.\n", + |\n\n\n\n\n5 |\n6 |Followed by 5x empty\n\n\n\n\n7 |\n8 \ + |Followed by 4x empty\n\n\n\n\n9 |Nonempty\n10 |Nonempty\n11 \ + |Nonempty.\n", ), ] { new_ucmd!() diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index f15371aed..64fc5360d 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -15,16 +15,25 @@ fn test_from_iec() { .args(&["--from=iec"]) .pipe_in("1024\n1.1M\n0.1G") .run() - .stdout_is("1024\n1153434\n107374182\n"); + .stdout_is("1024\n1153434\n107374183\n"); } #[test] fn test_from_iec_i() { new_ucmd!() .args(&["--from=iec-i"]) - .pipe_in("1024\n1.1Mi\n0.1Gi") + .pipe_in("1.1Mi\n0.1Gi") .run() - .stdout_is("1024\n1153434\n107374182\n"); + .stdout_is("1153434\n107374183\n"); +} + +#[test] +#[ignore] // FIXME: GNU from iec-i requires suffix +fn test_from_iec_i_requires_suffix() { + new_ucmd!() + .args(&["--from=iec-i", "1024"]) + .fails() + .stderr_is("numfmt: missing 'i' suffix in input: ‘1024’ (e.g Ki/Mi/Gi)"); } #[test] @@ -42,7 +51,7 @@ fn test_to_si() { .args(&["--to=si"]) .pipe_in("1000\n1100000\n100000000") .run() - .stdout_is("1.0K\n1.1M\n100.0M\n"); + .stdout_is("1.0K\n1.1M\n100M\n"); } #[test] @@ -51,7 +60,7 @@ fn test_to_iec() { .args(&["--to=iec"]) .pipe_in("1024\n1153434\n107374182") .run() - .stdout_is("1.0K\n1.1M\n102.4M\n"); + .stdout_is("1.0K\n1.2M\n103M\n"); } #[test] @@ -60,7 +69,7 @@ fn test_to_iec_i() { .args(&["--to=iec-i"]) .pipe_in("1024\n1153434\n107374182") .run() - .stdout_is("1.0Ki\n1.1Mi\n102.4Mi\n"); + .stdout_is("1.0Ki\n1.2Mi\n103Mi\n"); } #[test] @@ -142,7 +151,7 @@ fn test_negative() { .args(&["--to=iec-i"]) .pipe_in("-1024\n-1153434\n-107374182") .run() - .stdout_is("-1.0Ki\n-1.1Mi\n-102.4Mi\n"); + .stdout_is("-1.0Ki\n-1.2Mi\n-103Mi\n"); } #[test] @@ -159,7 +168,7 @@ fn test_normalize() { .args(&["--from=si", "--to=si"]) .pipe_in("10000000K\n0.001K") .run() - .stdout_is("10.0G\n1\n"); + .stdout_is("10G\n1\n"); } #[test] @@ -167,7 +176,7 @@ fn test_si_to_iec() { new_ucmd!() .args(&["--from=si", "--to=iec", "15334263563K"]) .run() - .stdout_is("13.9T\n"); + .stdout_is("14T\n"); } #[test] @@ -279,3 +288,193 @@ fn test_should_calculate_implicit_padding_per_free_argument() { .run() .stdout_is(" 1024\n 2000\n"); } + +#[test] +fn test_to_si_should_truncate_output() { + new_ucmd!() + .args(&["--to=si"]) + .pipe_in_fixture("gnutest_si_input.txt") + .succeeds() + .stdout_is_fixture("gnutest_si_result.txt"); +} + +#[test] +fn test_to_iec_should_truncate_output() { + new_ucmd!() + .args(&["--to=iec"]) + .pipe_in_fixture("gnutest_iec_input.txt") + .succeeds() + .stdout_is_fixture("gnutest_iec_result.txt"); +} + +#[test] +fn test_to_iec_i_should_truncate_output() { + new_ucmd!() + .args(&["--to=iec-i"]) + .pipe_in_fixture("gnutest_iec_input.txt") + .succeeds() + .stdout_is_fixture("gnutest_iec-i_result.txt"); +} + +#[test] +fn test_format_selected_field() { + new_ucmd!() + .args(&["--from=auto", "--field", "3", "1K 2K 3K"]) + .succeeds() + .stdout_only("1K 2K 3000\n"); + new_ucmd!() + .args(&["--from=auto", "--field", "2", "1K 2K 3K"]) + .succeeds() + .stdout_only("1K 2000 3K\n"); +} + +#[test] +fn test_format_selected_fields() { + new_ucmd!() + .args(&["--from=auto", "--field", "1,4,3", "1K 2K 3K 4K 5K 6K"]) + .succeeds() + .stdout_only("1000 2K 3000 4000 5K 6K\n"); +} + +#[test] +fn test_should_succeed_if_selected_field_out_of_range() { + new_ucmd!() + .args(&["--from=auto", "--field", "9", "1K 2K 3K"]) + .succeeds() + .stdout_only("1K 2K 3K\n"); +} + +#[test] +fn test_format_selected_field_range() { + new_ucmd!() + .args(&["--from=auto", "--field", "2-5", "1K 2K 3K 4K 5K 6K"]) + .succeeds() + .stdout_only("1K 2000 3000 4000 5000 6K\n"); +} + +#[test] +fn test_should_succeed_if_range_out_of_bounds() { + new_ucmd!() + .args(&["--from=auto", "--field", "5-10", "1K 2K 3K 4K 5K 6K"]) + .succeeds() + .stdout_only("1K 2K 3K 4K 5000 6000\n"); +} + +#[test] +fn test_implied_initial_field_value() { + new_ucmd!() + .args(&["--from=auto", "--field", "-2", "1K 2K 3K"]) + .succeeds() + .stdout_only("1000 2000 3K\n"); + + // same as above but with the equal sign + new_ucmd!() + .args(&["--from=auto", "--field=-2", "1K 2K 3K"]) + .succeeds() + .stdout_only("1000 2000 3K\n"); +} + +#[test] +fn test_field_df_example() { + // df -B1 | numfmt --header --field 2-4 --to=si + new_ucmd!() + .args(&["--header", "--field", "2-4", "--to=si"]) + .pipe_in_fixture("df_input.txt") + .succeeds() + .stdout_is_fixture("df_expected.txt"); +} + +#[test] +fn test_delimiter_must_not_be_empty() { + new_ucmd!().args(&["-d"]).fails(); +} + +#[test] +fn test_delimiter_must_not_be_more_than_one_character() { + new_ucmd!() + .args(&["--delimiter", "sad"]) + .fails() + .stderr_is("numfmt: the delimiter must be a single character"); +} + +#[test] +fn test_delimiter_only() { + new_ucmd!() + .args(&["-d", ","]) + .pipe_in("1234,56") + .succeeds() + .stdout_only("1234,56\n"); +} + +#[test] +fn test_line_is_field_with_no_delimiter() { + new_ucmd!() + .args(&["-d,", "--to=iec"]) + .pipe_in("123456") + .succeeds() + .stdout_only("121K\n"); +} + +#[test] +fn test_delimiter_to_si() { + new_ucmd!() + .args(&["-d=,", "--to=si"]) + .pipe_in("1234,56") + .succeeds() + .stdout_only("1.3K,56\n"); +} + +#[test] +fn test_delimiter_skips_leading_whitespace() { + new_ucmd!() + .args(&["-d=,", "--to=si"]) + .pipe_in(" \t 1234,56") + .succeeds() + .stdout_only("1.3K,56\n"); +} + +#[test] +fn test_delimiter_preserves_leading_whitespace_in_unselected_fields() { + new_ucmd!() + .args(&["-d=|", "--to=si"]) + .pipe_in(" 1000| 2000") + .succeeds() + .stdout_only("1.0K| 2000\n"); +} + +#[test] +fn test_delimiter_from_si() { + new_ucmd!() + .args(&["-d=,", "--from=si"]) + .pipe_in("1.2K,56") + .succeeds() + .stdout_only("1200,56\n"); +} + +#[test] +fn test_delimiter_overrides_whitespace_separator() { + // GNU numfmt reports this as “invalid suffix” + new_ucmd!() + .args(&["-d,"]) + .pipe_in("1 234,56") + .fails() + .stderr_is("numfmt: invalid number: ‘1 234’\n"); +} + +#[test] +fn test_delimiter_with_padding() { + new_ucmd!() + .args(&["-d=|", "--to=si", "--padding=5"]) + .pipe_in("1000|2000") + .succeeds() + .stdout_only(" 1.0K|2000\n"); +} + +#[test] +fn test_delimiter_with_padding_and_fields() { + new_ucmd!() + .args(&["-d=|", "--to=si", "--padding=5", "--field=-"]) + .pipe_in("1000|2000") + .succeeds() + .stdout_only(" 1.0K| 2.0K\n"); +} diff --git a/tests/by-util/test_paste.rs b/tests/by-util/test_paste.rs index 27de0b445..4604c5cf5 100644 --- a/tests/by-util/test_paste.rs +++ b/tests/by-util/test_paste.rs @@ -1,9 +1,104 @@ use crate::common::util::*; +struct TestData<'b> { + name: &'b str, + args: &'b [&'b str], + ins: &'b [&'b str], + out: &'b str, +} + +static EXAMPLE_DATA: &'static [TestData<'static>] = &[ + // Ensure that paste properly handles files lacking a final newline. + TestData { + name: "no-nl-1", + args: &[], + ins: &["a", "b"], + out: "a\tb\n", + }, + TestData { + name: "no-nl-2", + args: &[], + ins: &["a\n", "b"], + out: "a\tb\n", + }, + TestData { + name: "no-nl-3", + args: &[], + ins: &["a", "b\n"], + out: "a\tb\n", + }, + TestData { + name: "no-nl-4", + args: &[], + ins: &["a\n", "b\n"], + out: "a\tb\n", + }, + // Same as above, but with a two lines in each input file and the + // addition of the -d option to make SPACE be the output + // delimiter. + TestData { + name: "no-nla-1", + args: &["-d", " "], + ins: &["1\na", "2\nb"], + out: "1 2\na b\n", + }, + TestData { + name: "no-nla-2", + args: &["-d", " "], + ins: &["1\na\n", "2\nb"], + out: "1 2\na b\n", + }, + TestData { + name: "no-nla-3", + args: &["-d", " "], + ins: &["1\na", "2\nb\n"], + out: "1 2\na b\n", + }, + TestData { + name: "no-nla-4", + args: &["-d", " "], + ins: &["1\na\n", "2\nb\n"], + out: "1 2\na b\n", + }, +]; + #[test] fn test_combine_pairs_of_lines() { - new_ucmd!() - .args(&["-s", "-d", "\t\n", "html_colors.txt"]) - .run() - .stdout_is_fixture("html_colors.expected"); + for s in vec!["-s", "--serial"] { + for d in vec!["-d", "--delimiters"] { + new_ucmd!() + .args(&[s, d, "\t\n", "html_colors.txt"]) + .run() + .stdout_is_fixture("html_colors.expected"); + } + } +} + +#[test] +fn test_multi_stdin() { + for d in vec!["-d", "--delimiters"] { + new_ucmd!() + .args(&[d, "\t\n", "-", "-"]) + .pipe_in_fixture("html_colors.txt") + .succeeds() + .stdout_is_fixture("html_colors.expected"); + } +} + +#[test] +fn test_data() { + for example in EXAMPLE_DATA { + let (at, mut ucmd) = at_and_ucmd!(); + let mut ins = vec![]; + for (i, _in) in example.ins.iter().enumerate() { + let file = format!("in{}", i); + at.write(&file, _in); + ins.push(file); + } + println!("{}", example.name); + ucmd.args(example.args) + .args(&ins) + .succeeds() + .stdout_is(example.out); + } } diff --git a/tests/by-util/test_ptx.rs b/tests/by-util/test_ptx.rs index 77117c5c0..e44943bfa 100644 --- a/tests/by-util/test_ptx.rs +++ b/tests/by-util/test_ptx.rs @@ -8,6 +8,22 @@ fn gnu_ext_disabled_roff_no_ref() { .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); } +#[test] +fn gnu_ext_disabled_roff_no_ref_empty_word_regexp() { + new_ucmd!() + .args(&["-G", "-R", "-W", "", "input"]) + .succeeds() + .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); +} + +#[test] +fn gnu_ext_disabled_roff_no_ref_word_regexp_exc_space() { + new_ucmd!() + .args(&["-G", "-R", "-W", "[^\t\n]+", "input"]) + .succeeds() + .stdout_only_fixture("gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected"); +} + #[test] fn gnu_ext_disabled_roff_input_ref() { new_ucmd!() diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index f9a4dd0d5..c3635d202 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -148,7 +148,7 @@ fn test_rm_errors() { // rm: error: could not remove directory 'test_rm_errors_directory' (did you mean to pass '-r'?) ucmd.arg(dir).fails().stderr_is( "rm: error: could not remove directory 'test_rm_errors_directory' (did you mean \ - to pass '-r'?)\n", + to pass '-r' or '-R'?)\n", ); } diff --git a/tests/by-util/test_rmdir.rs b/tests/by-util/test_rmdir.rs index 5f87b5af6..34531cf22 100644 --- a/tests/by-util/test_rmdir.rs +++ b/tests/by-util/test_rmdir.rs @@ -40,7 +40,7 @@ fn test_rmdir_nonempty_directory_no_parents() { ucmd.arg(dir).fails().stderr_is( "rmdir: error: failed to remove 'test_rmdir_nonempty_no_parents': Directory not \ - empty\n", + empty\n", ); assert!(at.dir_exists(dir)); @@ -60,9 +60,9 @@ fn test_rmdir_nonempty_directory_with_parents() { ucmd.arg("-p").arg(dir).fails().stderr_is( "rmdir: error: failed to remove 'test_rmdir_nonempty/with/parents': Directory not \ - empty\nrmdir: error: failed to remove 'test_rmdir_nonempty/with': Directory not \ - empty\nrmdir: error: failed to remove 'test_rmdir_nonempty': Directory not \ - empty\n", + empty\nrmdir: error: failed to remove 'test_rmdir_nonempty/with': Directory not \ + empty\nrmdir: error: failed to remove 'test_rmdir_nonempty': Directory not \ + empty\n", ); assert!(at.dir_exists(dir)); diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index d4cff9aaa..a74938377 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -45,4 +45,3 @@ fn test_seq_wrong_arg() { fn test_zero_step() { new_ucmd!().args(&["10", "0", "32"]).fails(); } - diff --git a/tests/by-util/test_sleep.rs b/tests/by-util/test_sleep.rs index 651491045..a17beddf6 100644 --- a/tests/by-util/test_sleep.rs +++ b/tests/by-util/test_sleep.rs @@ -1 +1,112 @@ -// ToDO: add tests +use crate::common::util::*; + +use std::time::{Duration, Instant}; + +#[test] +fn test_sleep_no_suffix() { + let millis_100 = Duration::from_millis(100); + let before_test = Instant::now(); + + new_ucmd!().args(&["0.1"]).succeeds().stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_100); +} + +#[test] +fn test_sleep_s_suffix() { + let millis_100 = Duration::from_millis(100); + let before_test = Instant::now(); + + new_ucmd!().args(&["0.1s"]).succeeds().stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_100); +} + +#[test] +fn test_sleep_m_suffix() { + let millis_600 = Duration::from_millis(600); + let before_test = Instant::now(); + + new_ucmd!().args(&["0.01m"]).succeeds().stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_600); +} + +#[test] +fn test_sleep_h_suffix() { + let millis_360 = Duration::from_millis(360); + let before_test = Instant::now(); + + new_ucmd!().args(&["0.0001h"]).succeeds().stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_360); +} + +#[test] +fn test_sleep_negative_duration() { + new_ucmd!().args(&["-1"]).fails(); + new_ucmd!().args(&["-1s"]).fails(); + new_ucmd!().args(&["-1m"]).fails(); + new_ucmd!().args(&["-1h"]).fails(); + new_ucmd!().args(&["-1d"]).fails(); +} + +#[test] +fn test_sleep_zero_duration() { + new_ucmd!().args(&["0"]).succeeds().stdout_only(""); + new_ucmd!().args(&["0s"]).succeeds().stdout_only(""); + new_ucmd!().args(&["0m"]).succeeds().stdout_only(""); + new_ucmd!().args(&["0h"]).succeeds().stdout_only(""); + new_ucmd!().args(&["0d"]).succeeds().stdout_only(""); +} + +#[test] +fn test_sleep_no_argument() { + new_ucmd!().fails(); +} + +#[test] +fn test_sleep_sum_duration_same_suffix() { + let millis_200 = Duration::from_millis(100 + 100); + let before_test = Instant::now(); + + new_ucmd!() + .args(&["0.1s", "0.1s"]) + .succeeds() + .stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_200); +} + +#[test] +fn test_sleep_sum_duration_different_suffix() { + let millis_700 = Duration::from_millis(100 + 600); + let before_test = Instant::now(); + + new_ucmd!() + .args(&["0.1s", "0.01m"]) + .succeeds() + .stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_700); +} + +#[test] +fn test_sleep_sum_duration_many() { + let millis_900 = Duration::from_millis(100 + 100 + 300 + 400); + let before_test = Instant::now(); + + new_ucmd!() + .args(&["0.1s", "0.1s", "0.3s", "0.4s"]) + .succeeds() + .stdout_only(""); + + let duration = before_test.elapsed(); + assert!(duration >= millis_900); +} diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index edea760c2..592516cca 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -5,14 +5,7 @@ use crate::common::util::*; // utility that requires executing another program (kill, for instance) #[test] fn test_subcommand_retcode() { - new_ucmd!() - .arg("1") - .arg("true") - .succeeds(); + new_ucmd!().arg("1").arg("true").succeeds(); - new_ucmd!() - .arg("1") - .arg("false") - .run() - .status_code(1); + new_ucmd!().arg("1").arg("false").run().status_code(1); } diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index 7e04beced..9921c16b5 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -203,6 +203,53 @@ fn test_touch_set_only_mtime_failed() { ucmd.args(&["-t", "2015010112342", "-m", file]).fails(); } +#[test] +fn test_touch_set_both_time_and_reference() { + let (at, mut ucmd) = at_and_ucmd!(); + let ref_file = "test_touch_reference"; + let file = "test_touch_set_both_time_and_reference"; + + let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000"); + + at.touch(ref_file); + set_file_times(&at, ref_file, start_of_year, start_of_year); + assert!(at.file_exists(ref_file)); + + ucmd.args(&["-t", "2015010112342", "-r", ref_file, file]) + .fails(); +} + +#[test] +fn test_touch_set_both_date_and_reference() { + let (at, mut ucmd) = at_and_ucmd!(); + let ref_file = "test_touch_reference"; + let file = "test_touch_set_both_date_and_reference"; + + let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000"); + + at.touch(ref_file); + set_file_times(&at, ref_file, start_of_year, start_of_year); + assert!(at.file_exists(ref_file)); + + ucmd.args(&["-d", "Thu Jan 01 12:34:00 2015", "-r", ref_file, file]) + .fails(); +} + +#[test] +fn test_touch_set_both_time_and_date() { + let (_at, mut ucmd) = at_and_ucmd!(); + let file = "test_touch_set_both_time_and_date"; + + ucmd.args(&[ + "-t", + "2015010112342", + "-d", + "Thu Jan 01 12:34:00 2015", + file, + ]) + .fails(); +} + #[test] fn test_touch_set_only_mtime() { let (at, mut ucmd) = at_and_ucmd!(); diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index b32d98d29..a1500bcf6 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -134,3 +134,66 @@ fn missing_required_second_arg_fails() { assert!(!result.success); assert!(result.stderr.contains("missing operand after")); } + +#[test] +fn test_interpret_backslash_escapes() { + new_ucmd!() + .args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) + .pipe_in("abfnrtv") + .succeeds() + .stdout_is("\u{7}\u{8}\u{c}\n\r\t\u{b}"); +} + +#[test] +fn test_interpret_unrecognized_backslash_escape_as_character() { + new_ucmd!() + .args(&["qcz+=~-", r"\q\c\z\+\=\~\-"]) + .pipe_in("qcz+=~-") + .succeeds() + .stdout_is("qcz+=~-"); +} + +#[test] +fn test_interpret_single_octal_escape() { + new_ucmd!() + .args(&["X", r"\015"]) + .pipe_in("X") + .succeeds() + .stdout_is("\r"); +} + +#[test] +fn test_interpret_one_and_two_digit_octal_escape() { + new_ucmd!() + .args(&["XYZ", r"\0\11\77"]) + .pipe_in("XYZ") + .succeeds() + .stdout_is("\0\t?"); +} + +#[test] +fn test_octal_escape_is_at_most_three_digits() { + new_ucmd!() + .args(&["XY", r"\0156"]) + .pipe_in("XY") + .succeeds() + .stdout_is("\r6"); +} + +#[test] +fn test_non_octal_digit_ends_escape() { + new_ucmd!() + .args(&["rust", r"\08\11956"]) + .pipe_in("rust") + .succeeds() + .stdout_is("\08\t9"); +} + +#[test] +fn test_interpret_backslash_at_eol_literally() { + new_ucmd!() + .args(&["X", r"\"]) + .pipe_in("X") + .succeeds() + .stdout_is("\\"); +} diff --git a/tests/by-util/test_uniq.rs b/tests/by-util/test_uniq.rs index 53d57b49c..22e67540e 100644 --- a/tests/by-util/test_uniq.rs +++ b/tests/by-util/test_uniq.rs @@ -138,3 +138,12 @@ fn test_stdin_zero_terminated() { .run() .stdout_is_fixture("sorted-zero-terminated.expected"); } + +#[test] +fn test_invalid_utf8() { + new_ucmd!() + .arg("not-utf8-sequence.txt") + .run() + .failure() + .stderr_only("uniq: error: invalid utf-8 sequence of 1 bytes from index 0"); +} diff --git a/tests/by-util/test_unlink.rs b/tests/by-util/test_unlink.rs index daac6d3b3..fa8f962c4 100644 --- a/tests/by-util/test_unlink.rs +++ b/tests/by-util/test_unlink.rs @@ -23,7 +23,7 @@ fn test_unlink_multiple_files() { ucmd.arg(file_a).arg(file_b).fails().stderr_is( "unlink: error: extra operand: 'test_unlink_multiple_file_b'\nTry 'unlink --help' \ - for more information.\n", + for more information.\n", ); } @@ -36,7 +36,7 @@ fn test_unlink_directory() { ucmd.arg(dir).fails().stderr_is( "unlink: error: cannot unlink 'test_unlink_empty_directory': Not a regular file \ - or symlink\n", + or symlink\n", ); } @@ -46,6 +46,6 @@ fn test_unlink_nonexistent() { new_ucmd!().arg(file).fails().stderr_is( "unlink: error: Cannot stat 'test_unlink_nonexistent': No such file or directory \ - (os error 2)\n", + (os error 2)\n", ); } diff --git a/tests/by-util/test_wc.rs b/tests/by-util/test_wc.rs index fc9c00ecc..b064d7e0e 100644 --- a/tests/by-util/test_wc.rs +++ b/tests/by-util/test_wc.rs @@ -81,6 +81,6 @@ fn test_multiple_default() { .run() .stdout_is( " 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \ - alice_in_wonderland.txt\n 36 370 2189 total\n", + alice_in_wonderland.txt\n 36 370 2189 total\n", ); } diff --git a/tests/common/util.rs b/tests/common/util.rs index 6b85c8561..0f1acd49a 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -261,8 +261,8 @@ impl AtPath { } pub fn write(&self, name: &str, contents: &str) { - let mut f = self.open(name); - let _ = f.write(contents.as_bytes()); + log_info("open(write)", self.plus_as_string(name)); + let _ = std::fs::write(self.plus(name), contents); } pub fn append(&self, name: &str, contents: &str) { diff --git a/tests/fixtures/head/zero_terminated.expected b/tests/fixtures/head/zero_terminated.expected new file mode 100644 index 000000000..3c4cc058c Binary files /dev/null and b/tests/fixtures/head/zero_terminated.expected differ diff --git a/tests/fixtures/head/zero_terminated.txt b/tests/fixtures/head/zero_terminated.txt new file mode 100644 index 000000000..6c7968122 Binary files /dev/null and b/tests/fixtures/head/zero_terminated.txt differ diff --git a/tests/fixtures/numfmt/df_expected.txt b/tests/fixtures/numfmt/df_expected.txt new file mode 100644 index 000000000..ea8c3d79f --- /dev/null +++ b/tests/fixtures/numfmt/df_expected.txt @@ -0,0 +1,8 @@ +Filesystem 1B-blocks Used Available Use% Mounted on +udev 8.2G 0 8.2G 0% /dev +tmpfs 1.7G 2.1M 1.7G 1% /run +/dev/nvme0n1p2 1.1T 433G 523G 46% / +tmpfs 8.3G 145M 8.1G 2% /dev/shm +tmpfs 5.3M 4.1K 5.3M 1% /run/lock +tmpfs 8.3G 0 8.3G 0% /sys/fs/cgroup +/dev/nvme0n1p1 536M 8.2M 528M 2% /boot/efi diff --git a/tests/fixtures/numfmt/df_input.txt b/tests/fixtures/numfmt/df_input.txt new file mode 100644 index 000000000..4c094d54f --- /dev/null +++ b/tests/fixtures/numfmt/df_input.txt @@ -0,0 +1,8 @@ +Filesystem 1B-blocks Used Available Use% Mounted on +udev 8192688128 0 8192688128 0% /dev +tmpfs 1643331584 2015232 1641316352 1% /run +/dev/nvme0n1p2 1006530654208 432716689408 522613624832 46% / +tmpfs 8216649728 144437248 8072212480 2% /dev/shm +tmpfs 5242880 4096 5238784 1% /run/lock +tmpfs 8216649728 0 8216649728 0% /sys/fs/cgroup +/dev/nvme0n1p1 535805952 8175616 527630336 2% /boot/efi diff --git a/tests/fixtures/numfmt/gnutest_iec-i_result.txt b/tests/fixtures/numfmt/gnutest_iec-i_result.txt new file mode 100644 index 000000000..b4c286fc6 --- /dev/null +++ b/tests/fixtures/numfmt/gnutest_iec-i_result.txt @@ -0,0 +1,49 @@ +-1.1Ki +-1.1Ki +-1.0Ki +-1.0Ki +-1023 +0 +1 +1023 +1.0Ki +1.1Ki +1.1Ki +1.2Ki +1.5Ki +1.6Ki +1.9Ki +2.0Ki +2.0Ki +2.0Ki +2.0Ki +2.1Ki +10Ki +10Ki +10Ki +100Ki +100Ki +100Ki +949Ki +950Ki +950Ki +951Ki +951Ki +952Ki +990Ki +991Ki +995Ki +995Ki +996Ki +996Ki +997Ki +999Ki +1000Ki +1023Ki +1.0Mi +1.0Mi +1.0Mi +1.1Mi +1.0Gi +1.0Gi +1.1Gi diff --git a/tests/fixtures/numfmt/gnutest_iec_input.txt b/tests/fixtures/numfmt/gnutest_iec_input.txt new file mode 100644 index 000000000..bd7e867d5 --- /dev/null +++ b/tests/fixtures/numfmt/gnutest_iec_input.txt @@ -0,0 +1,49 @@ +-1025 +-1024.1 +-1024 +-1023.1 +-1023 +0 +1 +1023 +1024 +1025 +1126 +1127 +1536 +1537 +1945 +1946 +1996 +1997 +2048 +2049 +10188 +10189 +10240 +102348 +102349 +102400 +971776 +972288 +972800 +972801 +973824 +973825 +1013760 +1013761 +1018879 +1018880 +1018881 +1019904 +1019905 +1022976 +1022977 +1047552 +1047553 +1048575 +1048576 +1048577 +1073741823 +1073741824 +1073741825 diff --git a/tests/fixtures/numfmt/gnutest_iec_result.txt b/tests/fixtures/numfmt/gnutest_iec_result.txt new file mode 100644 index 000000000..61c5515b8 --- /dev/null +++ b/tests/fixtures/numfmt/gnutest_iec_result.txt @@ -0,0 +1,49 @@ +-1.1K +-1.1K +-1.0K +-1.0K +-1023 +0 +1 +1023 +1.0K +1.1K +1.1K +1.2K +1.5K +1.6K +1.9K +2.0K +2.0K +2.0K +2.0K +2.1K +10K +10K +10K +100K +100K +100K +949K +950K +950K +951K +951K +952K +990K +991K +995K +995K +996K +996K +997K +999K +1000K +1023K +1.0M +1.0M +1.0M +1.1M +1.0G +1.0G +1.1G diff --git a/tests/fixtures/numfmt/gnutest_si_input.txt b/tests/fixtures/numfmt/gnutest_si_input.txt new file mode 100644 index 000000000..3fcf4f9ff --- /dev/null +++ b/tests/fixtures/numfmt/gnutest_si_input.txt @@ -0,0 +1,39 @@ +-1001 +-999.1 +-999 +1 +500 +999 +999.1 +1000 +1000.1 +1001 +9900 +9901 +9949 +9950 +9951 +10000 +10001 +10500 +10999 +50000 +99000 +99001 +99900 +99949 +99950 +100000 +100001 +100999 +101000 +101001 +999000 +999001 +999949 +999950 +999999 +1000000 +1000001 +999000000.1 +999000001 diff --git a/tests/fixtures/numfmt/gnutest_si_result.txt b/tests/fixtures/numfmt/gnutest_si_result.txt new file mode 100644 index 000000000..7238ba40c --- /dev/null +++ b/tests/fixtures/numfmt/gnutest_si_result.txt @@ -0,0 +1,39 @@ +-1.1K +-1.0K +-999 +1 +500 +999 +1.0K +1.0K +1.1K +1.1K +9.9K +10K +10K +10K +10K +10K +11K +11K +11K +50K +99K +100K +100K +100K +100K +100K +101K +101K +101K +102K +999K +1.0M +1.0M +1.0M +1.0M +1.0M +1.1M +1.0G +1.0G diff --git a/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected b/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected new file mode 100644 index 000000000..141e6c9f8 --- /dev/null +++ b/tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected @@ -0,0 +1,7 @@ +.xx "" "" """quotes"", for roff" "" +.xx "" "" "and some other like %a, b#, c$c" "" +.xx "" "" "hello world!" "" +.xx "" "" "let's check special characters:" "" +.xx "" "" "maybe also~or^" "" +.xx "" "" "oh, and back\slash" "" +.xx "" "" "{brackets} for tex" "" diff --git a/tests/fixtures/uniq/not-utf8-sequence.txt b/tests/fixtures/uniq/not-utf8-sequence.txt new file mode 100644 index 000000000..78c146ffd --- /dev/null +++ b/tests/fixtures/uniq/not-utf8-sequence.txt @@ -0,0 +1,2 @@ +Next line contains two bytes - 0xCC and 0xCD - which are not a valid utf-8 sequence + \ No newline at end of file diff --git a/tests/fixtures/uniq/skip-2-fields.expected b/tests/fixtures/uniq/skip-2-fields.expected index 8cffc2ebc..b971c2b2b 100644 --- a/tests/fixtures/uniq/skip-2-fields.expected +++ b/tests/fixtures/uniq/skip-2-fields.expected @@ -1,2 +1,2 @@ - aaa aa a + aaa ⟪⟫ a aa a diff --git a/tests/fixtures/uniq/skip-fields.txt b/tests/fixtures/uniq/skip-fields.txt index f84e377a0..4ec2744c6 100644 --- a/tests/fixtures/uniq/skip-fields.txt +++ b/tests/fixtures/uniq/skip-fields.txt @@ -1,4 +1,4 @@ - aaa aa a + aaa ⟪⟫ a ZZZ aa a ZZZ aa a ZZZ bb a diff --git a/util/publish.sh b/util/publish.sh new file mode 100644 index 000000000..0936238a8 --- /dev/null +++ b/util/publish.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +ARG="" +if test "$1" != "--do-it"; then + ARG="--dry-run --allow-dirty" +fi + +cd src/uucore/ +cargo publish $ARG +cd - + +cd src/uu/stdbuf/src/libstdbuf/ +cargo publish $ARG +cd - + +PROGS=$(ls -1d src/uu/*/) +for p in $PROGS; do + cd $p + cargo publish $ARG + cd - +done + +cargo publish $ARG diff --git a/util/update-version.sh b/util/update-version.sh new file mode 100644 index 000000000..584d13608 --- /dev/null +++ b/util/update-version.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# This is a stupid helper. I will mass replace all versions (including other crates) +# So, it should be triple-checked + + +FROM="0.0.3" +TO="0.0.4" + +UUCORE_FROM="0.0.6" +UUCORE_TO="0.0.7" + +PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml Cargo.toml) + +# update the version of all programs +sed -i -e "s|version = \"$FROM\"|version = \"$TO\"|" $PROGS + +# Update the stbuff stuff +sed -i -e "s|libstdbuf = { version=\"$FROM\"|libstdbuf = { version=\"$TO\"|" src/uu/stdbuf/Cargo.toml +sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=true, version=\"$TO\", package=\"uu_|g" Cargo.toml + +# Update uucore itself +sed -i -e "s|version = \"$UUCORE_FROM\"|version = \"$UUCORE_TO\"|" src/uucore/Cargo.toml +# Update crates using uucore +sed -i -e "s|uucore = { version=\">=$UUCORE_FROM\",|uucore = { version=\">=$UUCORE_TO\",|" $PROGS + +