1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

Merge branch 'master' into clap-pwd

This commit is contained in:
Sylvestre Ledru 2020-11-19 22:32:02 +01:00 committed by GitHub
commit 8271faf3a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
132 changed files with 3646 additions and 749 deletions

View file

@ -1,7 +1,7 @@
name: CICD
# spell-checker:ignore (acronyms) CICD MSVC musl
# spell-checker:ignore (env/flags) Ccodegen Coverflow Cpanic RUSTDOCFLAGS RUSTFLAGS Zpanic
# spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic RUSTDOCFLAGS RUSTFLAGS Zpanic
# spell-checker:ignore (jargon) SHAs deps softprops toolchain
# spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy
# spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
@ -145,10 +145,6 @@ jobs:
cargo fetch --locked --quiet
## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
RUSTUP_TOOLCHAIN=stable cargo-tree tree --frozen --all --no-dev-dependencies --no-indent --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique
- name: Info
shell: bash
run: |
# Info
- name: Test
uses: actions-rs/cargo@v1

55
.vscode/cSpell.json vendored
View file

@ -8,6 +8,8 @@
"Cygwin",
"FreeBSD",
"Gmail",
"GNUEABI",
"GNUEABIhf",
"Irix",
"MacOS",
"MinGW",
@ -23,16 +25,31 @@
"Xenix",
"flac",
"lzma",
// cargo
"cdylib",
"rlib",
// crates
"advapi",
"advapi32-sys",
"aho-corasick",
"backtrace",
"byteorder",
"chacha",
"chrono",
"conv",
"corasick",
"filetime",
"formatteriteminfo",
"getopts",
"itertools",
"memchr",
"multifilereader",
"onig",
"peekreader",
"quickcheck",
"rand_chacha",
"smallvec",
"tempfile",
"termion",
"termios",
"termsize",
@ -64,12 +81,14 @@
"colorize",
"consts",
"dedup",
"demangle",
"deque",
"dequeue",
"enqueue",
"executable",
"executables",
"gibibytes",
"hardfloat",
"hardlink",
"hardlinks",
"hashsums",
@ -87,9 +106,12 @@
"primality",
"pseudoprime",
"pseudoprimes",
"procs",
"readonly",
"seedable",
"semver",
"shortcode",
"shortcodes",
"symlink",
"symlinks",
"syscall",
@ -144,6 +166,7 @@
"Sunrin SHIMURA", "Sunrin", "SHIMURA",
"Smigle00", "Smigle",
"Sylvestre Ledru", "Sylvestre", "Ledru",
"T Jameson Little", "Jameson", "Little",
"Tobias Bohumir Schottdorf", "Tobias", "Bohumir", "Schottdorf",
"Virgile Andreani", "Virgile", "Andreani",
"Vsevolod Velichko", "Vsevolod", "Velichko",
@ -151,27 +174,37 @@
"Yury Krivopalov", "Yury", "Krivopalov",
"anonymousknight",
"kwantam",
"nicoo",
"rivy",
// rust
"clippy",
"concat",
"fract",
"powi",
"println",
"repr",
"rfind",
"rustc",
"rustfmt",
"struct",
"structs",
"substr",
"splitn",
"trunc",
// shell
"passwd",
"pipefail",
"tcsh",
// tags
"Maint",
// uutils
"chcon",
"chgrp",
"chmod",
"chown",
"chroot",
"cksum",
"csplit",
"dircolors",
"hashsum",
"hostid",
@ -190,16 +223,28 @@
"realpath",
"relpath",
"rmdir",
"runcon",
"shuf",
"stdbuf",
"stty",
"tsort",
"uname",
"unexpand",
"whoami",
// vars/errno
"errno",
"EOPNOTSUPP",
// vars/fcntl
"F_GETFL",
"GETFL",
"fcntl",
"vmsplice",
// vars/libc
"FILENO",
"HOSTSIZE",
"IDSIZE",
"IFIFO",
"IFREG",
"IRGRP",
"IROTH",
"IRUSR",
@ -240,10 +285,16 @@
"socktype",
"umask",
"waitpid",
// vars/nix
"iovec",
"unistd",
// vars/signals
"SIGPIPE",
// vars/sync
"Condvar",
// vars/stat
"fstat",
"stat",
// vars/time
"Timespec",
"nsec",
@ -265,9 +316,11 @@
"errhandlingapi",
"fileapi",
"handleapi",
"lmcons",
"minwindef",
"processthreadsapi",
"synchapi",
"sysinfoapi",
"winbase",
"winerror",
"winnt",
@ -285,10 +338,12 @@
"coreopts",
"coreutils",
"libc",
"libstdbuf",
"musl",
"ucmd",
"utmpx",
"uucore",
"uucore_procs",
"uumain",
"uutils"
],

2
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,2 @@
{
}

409
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -225,7 +225,7 @@ 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.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="src/uucore" }
# * uutils
uu_test = { optional=true, version="0.0.1", package="uu_test", path="src/uu/test" }
#
@ -324,6 +324,7 @@ whoami = { optional=true, version="0.0.1", package="uu_whoami", path="src/uu/w
yes = { optional=true, version="0.0.1", 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()`)
pin_rustc-demangle = { version="0.1.16, < 0.1.17", package="rustc-demangle" } ## rust-demangle v0.1.17 has compiler errors for MinRustV v1.32.0, expects 1.33
pin_same-file = { version="1.0.4, < 1.0.6", package="same-file" } ## same-file v1.0.6 has compiler errors for MinRustV v1.32.0, expects 1.34
pin_winapi-util = { version="0.1.2, < 0.1.3", package="winapi-util" } ## winapi-util v0.1.3 has compiler errors for MinRustV v1.32.0, expects 1.34
@ -338,7 +339,7 @@ sha1 = { version="0.6", features=["std"] }
tempfile = "3.1"
time = "0.1"
unindent = "0.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries"] }
uucore = { version=">=0.0.4", package="uucore", path="src/uucore", features=["entries"] }
[target.'cfg(unix)'.dev-dependencies]
rust-users = { version="0.10", package="users" }

View file

@ -16,8 +16,8 @@ path = "src/arch.rs"
[dependencies]
platform-info = "0.0.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "arch"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/base32.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features = ["encoding"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "base32"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/base64.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features = ["encoding"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "base64"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/basename.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "basename"

View file

@ -16,8 +16,8 @@ path = "src/cat.rs"
[dependencies]
quick-error = "1.2.3"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(unix)'.dependencies]
unix_socket = "0.5.0"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/chgrp.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries", "fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
walkdir = "2.2.8"
[[bin]]

View file

@ -16,8 +16,8 @@ path = "src/chmod.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs", "mode"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
walker = "1.0.0"
[[bin]]

View file

@ -16,8 +16,8 @@ path = "src/chown.rs"
[dependencies]
glob = "0.3.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries", "fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
walkdir = "2.2"
[[bin]]

View file

@ -16,8 +16,8 @@ path = "src/chroot.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "chroot"

View file

@ -16,8 +16,8 @@ path = "src/cksum.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "cksum"

View file

@ -17,8 +17,8 @@ path = "src/comm.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "comm"

View file

@ -23,8 +23,8 @@ clap = "2.32"
filetime = "0.2"
libc = "0.2.42"
quick-error = "1.2.3"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
walkdir = "2.2.8"
[target.'cfg(target_os = "linux")'.dependencies]

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/cut.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "cut"

View file

@ -17,8 +17,8 @@ path = "src/date.rs"
[dependencies]
chrono = "0.4.4"
clap = "2.32"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "date"

View file

@ -18,8 +18,8 @@ path = "src/df.rs"
clap = "2.32"
libc = "0.2"
number_prefix = "0.2"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "winerror"] }

View file

@ -16,8 +16,8 @@ path = "src/dircolors.rs"
[dependencies]
glob = "0.3.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "dircolors"

View file

@ -16,8 +16,8 @@ path = "src/dirname.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "dirname"

View file

@ -16,8 +16,8 @@ path = "src/du.rs"
[dependencies]
time = "0.1.40"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "du"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/echo.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "echo"

View file

@ -18,8 +18,8 @@ path = "src/env.rs"
clap = "2.33"
libc = "0.2.42"
rust-ini = "0.13.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "env"

View file

@ -17,8 +17,8 @@ path = "src/expand.rs"
[dependencies]
getopts = "0.2.18"
unicode-width = "0.1.5"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "expand"

View file

@ -17,8 +17,8 @@ path = "src/expr.rs"
[dependencies]
libc = "0.2.42"
onig = "~4.3.2"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "expr"

View file

@ -19,8 +19,8 @@ num-traits = "0.2" # used in src/numerics.rs, which is included by build.rs
num-traits = "0.2"
rand = { version="0.7", features=["small_rng"] }
smallvec = { version="0.6.13, < 1.0" }
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[dev-dependencies]
criterion = "0.3"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/false.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "false"

View file

@ -17,8 +17,8 @@ path = "src/fmt.rs"
[dependencies]
libc = "0.2.42"
unicode-width = "0.1.5"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "fmt"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/fold.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "fold"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/groups.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
clap = "2.32"
[[bin]]

View file

@ -25,8 +25,8 @@ regex-syntax = "0.6.7"
sha1 = "0.6.0"
sha2 = "0.6.0"
sha3 = "0.6.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "hashsum"

View file

@ -16,8 +16,8 @@ path = "src/head.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "head"

View file

@ -16,8 +16,8 @@ path = "src/hostid.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "hostid"

View file

@ -18,8 +18,8 @@ path = "src/hostname.rs"
clap = "2.32"
libc = "0.2.42"
hostname = { version = "0.3", features = ["set"] }
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["wide"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["wide"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
winapi = { version="0.3", features=["sysinfoapi", "winsock2"] }
[[bin]]

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/id.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "process"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "id"

View file

@ -18,10 +18,10 @@ edition = "2018"
path = "src/install.rs"
[dependencies]
getopts = "0.2.18"
clap = "2.33"
libc = ">= 0.2"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["mode"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["mode"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[dev-dependencies]
time = "0.1.40"

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) rwxr sourcepath targetpath
extern crate getopts;
extern crate clap;
extern crate libc;
mod mode;
@ -15,16 +15,12 @@ mod mode;
#[macro_use]
extern crate uucore;
use clap::{App, Arg, ArgMatches};
use std::fs;
use std::path::{Path, PathBuf};
use std::result::Result;
static NAME: &str = "install";
static SUMMARY: &str = "Copy SOURCE to DEST or multiple SOURCE(s) to the existing
DIRECTORY, while setting permission modes and owner/group";
static LONG_HELP: &str = "";
const DEFAULT_MODE: u32 = 755;
const DEFAULT_MODE: u32 = 0o755;
#[allow(dead_code)]
pub struct Behavior {
@ -52,14 +48,179 @@ impl Behavior {
}
}
static ABOUT: &str = "Copy SOURCE to DEST or multiple SOURCE(s) to the existing
DIRECTORY, while setting permission modes and owner/group";
static VERSION: &str = env!("CARGO_PKG_VERSION");
static OPT_COMPARE: &str = "compare";
static OPT_BACKUP: &str = "backup";
static OPT_BACKUP_2: &str = "backup2";
static OPT_DIRECTORY: &str = "directory";
static OPT_IGNORED: &str = "ignored";
static OPT_CREATED: &str = "created";
static OPT_GROUP: &str = "group";
static OPT_MODE: &str = "mode";
static OPT_OWNER: &str = "owner";
static OPT_PRESERVE_TIMESTAMPS: &str = "preserve-timestamps";
static OPT_STRIP: &str = "strip";
static OPT_STRIP_PROGRAM: &str = "strip-program";
static OPT_SUFFIX: &str = "suffix";
static OPT_TARGET_DIRECTORY: &str = "target-directory";
static OPT_NO_TARGET_DIRECTORY: &str = "no-target-directory";
static OPT_VERBOSE: &str = "verbose";
static OPT_PRESERVE_CONTEXT: &str = "preserve-context";
static OPT_CONTEXT: &str = "context";
static ARG_FILES: &str = "files";
fn get_usage() -> String {
format!("{0} [OPTION]... [FILE]...", executable!())
}
/// Main install utility function, called from main.rs.
///
/// Returns a program return code.
///
pub fn uumain(args: impl uucore::Args) -> i32 {
let args = args.collect_str();
let usage = get_usage();
let matches = parse_opts(args);
let matches = App::new(executable!())
.version(VERSION)
.about(ABOUT)
.usage(&usage[..])
.arg(
Arg::with_name(OPT_BACKUP)
.long(OPT_BACKUP)
.help("(unimplemented) make a backup of each existing destination file")
.value_name("CONTROL")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_BACKUP_2)
.short("b")
.help("(unimplemented) like --backup but does not accept an argument")
)
.arg(
Arg::with_name(OPT_IGNORED)
.short("c")
.help("ignored")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_COMPARE)
.short("C")
.long(OPT_COMPARE)
.help("(unimplemented) compare each pair of source and destination files, and in some cases, do not modify the destination at all")
)
.arg(
Arg::with_name(OPT_DIRECTORY)
.short("d")
.long(OPT_DIRECTORY)
.help("treat all arguments as directory names. create all components of the specified directories")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_CREATED)
.short("D")
.help("(unimplemented) create all leading components of DEST except the last, then copy SOURCE to DEST")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_GROUP)
.short("g")
.long(OPT_GROUP)
.help("(unimplemented) set group ownership, instead of process's current group")
.value_name("GROUP")
)
.arg(
Arg::with_name(OPT_MODE)
.short("m")
.long(OPT_MODE)
.help("set permission mode (as in chmod), instead of rwxr-xr-x")
.value_name("MODE")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_OWNER)
.short("o")
.long(OPT_OWNER)
.help("(unimplemented) set ownership (super-user only)")
.value_name("OWNER")
)
.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")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_STRIP)
.short("s")
.long(OPT_STRIP)
.help("(unimplemented) strip symbol tables")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_STRIP_PROGRAM)
.long(OPT_STRIP_PROGRAM)
.help("(unimplemented) program used to strip binaries")
.value_name("PROGRAM")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_SUFFIX)
.short("S")
.long(OPT_SUFFIX)
.help("(unimplemented) override the usual backup suffix")
.value_name("SUFFIX")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_TARGET_DIRECTORY)
.short("t")
.long(OPT_TARGET_DIRECTORY)
.help("(unimplemented) move all SOURCE arguments into DIRECTORY")
.value_name("DIRECTORY")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_NO_TARGET_DIRECTORY)
.short("T")
.long(OPT_NO_TARGET_DIRECTORY)
.help("(unimplemented) treat DEST as a normal file")
)
.arg(
Arg::with_name(OPT_VERBOSE)
.short("v")
.long(OPT_VERBOSE)
.help("explain what is being done")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_PRESERVE_CONTEXT)
.short("P")
.long(OPT_PRESERVE_CONTEXT)
.help("(unimplemented) preserve security context")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_CONTEXT)
.short("Z")
.long(OPT_CONTEXT)
.help("(unimplemented) set security context of files and directories")
.value_name("CONTEXT")
)
.arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true))
.get_matches_from(args);
let paths: Vec<String> = matches
.values_of(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default();
if let Err(s) = check_unimplemented(&matches) {
show_error!("Unimplemented feature: {}", s);
@ -73,146 +234,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
}
};
let paths: Vec<PathBuf> = {
#[allow(clippy::ptr_arg)]
fn string_to_path(s: &String) -> &Path {
Path::new(s)
};
let to_owned = |p: &Path| p.to_owned();
let arguments = matches.free.iter().map(string_to_path);
arguments.map(to_owned).collect()
};
match behavior.main_function {
MainFunction::Directory => directory(&paths[..], behavior),
MainFunction::Standard => standard(&paths[..], behavior),
MainFunction::Directory => directory(paths, behavior),
MainFunction::Standard => standard(paths, behavior),
}
}
/// Build a specification of the command line.
///
/// Returns a getopts::Options struct.
///
fn parse_opts(args: Vec<String>) -> getopts::Matches {
let syntax = format!(
"SOURCE DEST
{} SOURCE... DIRECTORY",
NAME
);
app!(&syntax, SUMMARY, LONG_HELP)
// TODO implement flag
.optflagopt(
"",
"backup",
"(unimplemented) make a backup of each existing destination\n \
file",
"CONTROL",
)
// TODO implement flag
.optflag(
"b",
"",
"(unimplemented) like --backup but does not accept an argument",
)
.optflag("c", "", "ignored")
// TODO implement flag
.optflag(
"C",
"compare",
"(unimplemented) compare each pair of source and destination\n \
files, and in some cases, do not modify the destination at all",
)
.optflag(
"d",
"directory",
"treat all arguments as directory names.\n \
create all components of the specified directories",
)
// TODO implement flag
.optflag(
"D",
"",
"(unimplemented) create all leading components of DEST except the\n \
last, then copy SOURCE to DEST",
)
// TODO implement flag
.optflagopt(
"g",
"group",
"(unimplemented) set group ownership, instead of process's\n \
current group",
"GROUP",
)
.optflagopt(
"m",
"mode",
"set permission mode (as in chmod), instead\n \
of rwxr-xr-x",
"MODE",
)
// TODO implement flag
.optflagopt(
"o",
"owner",
"(unimplemented) set ownership (super-user only)",
"OWNER",
)
// TODO implement flag
.optflag(
"p",
"preserve-timestamps",
"(unimplemented) apply access/modification times\n \
of SOURCE files to corresponding destination files",
)
// TODO implement flag
.optflag("s", "strip", "(unimplemented) strip symbol tables")
// TODO implement flag
.optflagopt(
"",
"strip-program",
"(unimplemented) program used to strip binaries",
"PROGRAM",
)
// TODO implement flag
.optopt(
"S",
"suffix",
"(unimplemented) override the usual backup suffix",
"SUFFIX",
)
// TODO implement flag
.optopt(
"t",
"target-directory",
"(unimplemented) move all SOURCE arguments into\n \
DIRECTORY",
"DIRECTORY",
)
// TODO implement flag
.optflag(
"T",
"no-target-directory",
"(unimplemented) treat DEST as a normal file",
)
.optflag("v", "verbose", "explain what is being done")
// TODO implement flag
.optflag(
"P",
"preserve-context",
"(unimplemented) preserve security context",
)
// TODO implement flag
.optflagopt(
"Z",
"context",
"(unimplemented) set security context of files and\n \
directories",
"CONTEXT",
)
.parse(args)
}
/// Check for unimplemented command line arguments.
///
/// Either return the degenerate Ok value, or an Err with string.
@ -221,34 +248,35 @@ fn parse_opts(args: Vec<String>) -> getopts::Matches {
///
/// Error datum is a string of the unimplemented argument.
///
fn check_unimplemented(matches: &getopts::Matches) -> Result<(), &str> {
if matches.opt_present("backup") {
///
fn check_unimplemented<'a>(matches: &ArgMatches) -> Result<(), &'a str> {
if matches.is_present(OPT_BACKUP) {
Err("--backup")
} else if matches.opt_present("b") {
} else if matches.is_present(OPT_BACKUP_2) {
Err("-b")
} else if matches.opt_present("compare") {
} else if matches.is_present(OPT_COMPARE) {
Err("--compare, -C")
} else if matches.opt_present("D") {
} else if matches.is_present(OPT_CREATED) {
Err("-D")
} else if matches.opt_present("group") {
} else if matches.is_present(OPT_GROUP) {
Err("--group, -g")
} else if matches.opt_present("owner") {
} else if matches.is_present(OPT_OWNER) {
Err("--owner, -o")
} else if matches.opt_present("preserve-timestamps") {
} else if matches.is_present(OPT_PRESERVE_TIMESTAMPS) {
Err("--preserve-timestamps, -p")
} else if matches.opt_present("strip") {
} else if matches.is_present(OPT_STRIP) {
Err("--strip, -s")
} else if matches.opt_present("strip-program") {
} else if matches.is_present(OPT_STRIP_PROGRAM) {
Err("--strip-program")
} else if matches.opt_present("suffix") {
} else if matches.is_present(OPT_SUFFIX) {
Err("--suffix, -S")
} else if matches.opt_present("target-directory") {
} else if matches.is_present(OPT_TARGET_DIRECTORY) {
Err("--target-directory, -t")
} else if matches.opt_present("no-target-directory") {
} else if matches.is_present(OPT_NO_TARGET_DIRECTORY) {
Err("--no-target-directory, -T")
} else if matches.opt_present("preserve-context") {
} else if matches.is_present(OPT_PRESERVE_CONTEXT) {
Err("--preserve-context, -P")
} else if matches.opt_present("context") {
} else if matches.is_present(OPT_CONTEXT) {
Err("--context, -Z")
} else {
Ok(())
@ -263,8 +291,8 @@ fn check_unimplemented(matches: &getopts::Matches) -> Result<(), &str> {
///
/// In event of failure, returns an integer intended as a program return code.
///
fn behavior(matches: &getopts::Matches) -> Result<Behavior, i32> {
let main_function = if matches.opt_present("directory") {
fn behavior(matches: &ArgMatches) -> Result<Behavior, i32> {
let main_function = if matches.is_present("directory") {
MainFunction::Directory
} else {
MainFunction::Standard
@ -272,8 +300,8 @@ fn behavior(matches: &getopts::Matches) -> Result<Behavior, i32> {
let considering_dir: bool = MainFunction::Directory == main_function;
let specified_mode: Option<u32> = if matches.opt_present("mode") {
match matches.opt_str("mode") {
let specified_mode: Option<u32> = if matches.is_present(OPT_MODE) {
match matches.value_of(OPT_MODE) {
Some(x) => match mode::parse(&x[..], considering_dir) {
Ok(y) => Some(y),
Err(err) => {
@ -285,7 +313,7 @@ fn behavior(matches: &getopts::Matches) -> Result<Behavior, i32> {
show_error!(
"option '--mode' requires an argument\n \
Try '{} --help' for more information.",
NAME
executable!()
);
return Err(1);
}
@ -294,27 +322,27 @@ fn behavior(matches: &getopts::Matches) -> Result<Behavior, i32> {
None
};
let backup_suffix = if matches.opt_present("suffix") {
match matches.opt_str("suffix") {
let backup_suffix = if matches.is_present(OPT_SUFFIX) {
match matches.value_of(OPT_SUFFIX) {
Some(x) => x,
None => {
show_error!(
"option '--suffix' requires an argument\n\
Try '{} --help' for more information.",
NAME
executable!()
);
return Err(1);
}
}
} else {
"~".to_owned()
"~"
};
Ok(Behavior {
main_function,
specified_mode,
suffix: backup_suffix,
verbose: matches.opt_present("v"),
suffix: backup_suffix.to_string(),
verbose: matches.is_present(OPT_VERBOSE),
})
}
@ -325,15 +353,15 @@ fn behavior(matches: &getopts::Matches) -> Result<Behavior, i32> {
///
/// Returns an integer intended as a program return code.
///
fn directory(paths: &[PathBuf], b: Behavior) -> i32 {
fn directory(paths: Vec<String>, b: Behavior) -> i32 {
if paths.is_empty() {
println!("{} with -d requires at least one argument.", NAME);
println!("{} with -d requires at least one argument.", executable!());
1
} else {
let mut all_successful = true;
for directory in paths.iter() {
let path = directory.as_path();
let path = Path::new(directory);
if path.exists() {
show_info!("cannot create directory '{}': File exists", path.display());
@ -371,18 +399,21 @@ fn is_new_file_path(path: &Path) -> bool {
///
/// Returns an integer intended as a program return code.
///
fn standard(paths: &[PathBuf], b: Behavior) -> i32 {
fn standard(paths: Vec<String>, b: Behavior) -> i32 {
if paths.len() < 2 {
println!("{} requires at least 2 arguments.", NAME);
println!("{} requires at least 2 arguments.", executable!());
1
} else {
let sources = &paths[0..paths.len() - 1];
let target = &paths[paths.len() - 1];
let sources = &paths[0..paths.len() - 1]
.iter()
.map(PathBuf::from)
.collect::<Vec<_>>();
let target = Path::new(paths.last().unwrap());
if (target.is_file() || is_new_file_path(target)) && sources.len() == 1 {
copy_file_to_file(&sources[0], target, &b)
copy_file_to_file(&sources[0], &target.to_path_buf(), &b)
} else {
copy_files_into_dir(sources, target, &b)
copy_files_into_dir(sources, &target.to_path_buf(), &b)
}
}
}

View file

@ -16,8 +16,8 @@ path = "src/join.rs"
[dependencies]
clap = "2.32"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "join"

View file

@ -16,8 +16,8 @@ path = "src/kill.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["signals"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["signals"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "kill"

View file

@ -16,8 +16,8 @@ path = "src/link.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "link"

View file

@ -16,8 +16,8 @@ path = "src/ln.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "ln"

View file

@ -16,8 +16,8 @@ path = "src/logname.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "logname"

View file

@ -23,8 +23,8 @@ term_grid = "0.1.5"
termsize = "0.1.6"
time = "0.1.40"
unicode-width = "0.1.5"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries", "fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "ls"

View file

@ -15,10 +15,10 @@ edition = "2018"
path = "src/mkdir.rs"
[dependencies]
getopts = "0.2.18"
clap = "2.33"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs", "mode"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mkdir"

View file

@ -5,53 +5,78 @@
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
extern crate getopts;
extern crate clap;
#[macro_use]
extern crate uucore;
use clap::{App, Arg};
use std::fs;
use std::path::Path;
static NAME: &str = "mkdir";
static ABOUT: &str = "Create the given DIRECTORY(ies) if they do not exist";
static VERSION: &str = env!("CARGO_PKG_VERSION");
static OPT_MODE: &str = "mode";
static OPT_PARENTS: &str = "parents";
static OPT_VERBOSE: &str = "verbose";
static ARG_DIRS: &str = "dirs";
fn get_usage() -> String {
format!("{0} [OPTION]... [USER]", executable!())
}
/**
* Handles option parsing
*/
pub fn uumain(args: impl uucore::Args) -> i32 {
let args = args.collect_str();
let mut opts = getopts::Options::new();
let usage = get_usage();
// Linux-specific options, not implemented
// opts.optflag("Z", "context", "set SELinux security context" +
// " of each created directory to CTX"),
opts.optopt("m", "mode", "set file mode", "755");
opts.optflag("p", "parents", "make parent directories as needed");
opts.optflag("v", "verbose", "print a message for each printed directory");
opts.optflag("h", "help", "display this help");
opts.optflag("V", "version", "display this version");
let matches = App::new(executable!())
.version(VERSION)
.about(ABOUT)
.usage(&usage[..])
.arg(
Arg::with_name(OPT_MODE)
.short("m")
.long(OPT_MODE)
.help("set file mode")
.default_value("755"),
)
.arg(
Arg::with_name(OPT_PARENTS)
.short("p")
.long(OPT_PARENTS)
.help("make parent directories as needed"),
)
.arg(
Arg::with_name(OPT_VERBOSE)
.short("v")
.long(OPT_VERBOSE)
.help("print a message for each printed directory"),
)
.arg(
Arg::with_name(ARG_DIRS)
.multiple(true)
.takes_value(true)
.min_values(1),
)
.get_matches_from(args);
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(f) => crash!(1, "Invalid options\n{}", f),
};
let dirs: Vec<String> = matches
.values_of(ARG_DIRS)
.map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default();
if args.len() == 1 || matches.opt_present("help") {
print_help(&opts);
return 0;
}
if matches.opt_present("version") {
println!("{} {}", NAME, VERSION);
return 0;
}
let verbose = matches.opt_present("verbose");
let recursive = matches.opt_present("parents");
let verbose = matches.is_present(OPT_VERBOSE);
let recursive = matches.is_present(OPT_PARENTS);
// Translate a ~str in octal form to u16, default to 755
// Not tested on Windows
let mode_match = matches.opts_str(&["mode".to_owned()]);
let mode_match = matches.value_of(OPT_MODE);
let mode: u16 = match mode_match {
Some(m) => {
let res: Option<u16> = u16::from_str_radix(&m, 8).ok();
@ -63,23 +88,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
_ => 0o755 as u16,
};
let dirs = matches.free;
if dirs.is_empty() {
crash!(1, "missing operand");
}
exec(dirs, recursive, mode, verbose)
}
fn print_help(opts: &getopts::Options) {
println!("{} {}", NAME, VERSION);
println!();
println!("Usage:");
print!(
"{}",
opts.usage("Create the given DIRECTORY(ies) if they do not exist")
);
}
/**
* Create the list of new directories
*/
@ -120,7 +131,7 @@ fn mkdir(path: &Path, recursive: bool, mode: u16, verbose: bool) -> i32 {
}
if verbose {
show_info!("created directory '{}'", path.display());
println!("{}: created directory '{}'", executable!(), path.display());
}
#[cfg(any(unix, target_os = "redox"))]

View file

@ -17,8 +17,8 @@ path = "src/mkfifo.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mkfifo"

View file

@ -18,8 +18,8 @@ path = "src/mknod.rs"
[dependencies]
getopts = "0.2.18"
libc = "^0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["mode"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["mode"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mknod"

View file

@ -18,8 +18,8 @@ path = "src/mktemp.rs"
getopts = "0.2.18"
rand = "0.5"
tempfile = "3.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mktemp"

View file

@ -16,8 +16,8 @@ path = "src/more.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(target_os = "redox")'.dependencies]
redox_termios = "0.1"

View file

@ -17,8 +17,8 @@ path = "src/mv.rs"
[dependencies]
getopts = "0.2.18"
fs_extra = "1.1.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mv"

View file

@ -17,8 +17,8 @@ path = "src/nice.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nice"

View file

@ -21,8 +21,8 @@ libc = "0.2.42"
memchr = "2.2.0"
regex = "1.0.1"
regex-syntax = "0.6.7"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nl"

View file

@ -17,8 +17,8 @@ path = "src/nohup.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nohup"

View file

@ -18,8 +18,8 @@ path = "src/nproc.rs"
libc = "0.2.42"
num_cpus = "1.10"
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nproc"

View file

@ -16,8 +16,8 @@ path = "src/numfmt.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "numfmt"

View file

@ -19,8 +19,8 @@ byteorder = "1.3.2"
getopts = "0.2.18"
half = "1.6"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "od"

View file

@ -16,8 +16,8 @@ path = "src/paste.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "paste"

View file

@ -17,8 +17,8 @@ path = "src/pathchk.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "pathchk"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/pinky.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["utmpx", "entries"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["utmpx", "entries"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "pinky"

View file

@ -16,8 +16,8 @@ path = "src/printenv.rs"
[dependencies]
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "printenv"

View file

@ -19,8 +19,8 @@ path = "src/printf.rs"
[dependencies]
itertools = "0.8.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "printf"

View file

@ -21,8 +21,8 @@ libc = "0.2.42"
memchr = "2.2.0"
regex = "1.0.1"
regex-syntax = "0.6.7"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "ptx"

View file

@ -16,8 +16,8 @@ path = "src/pwd.rs"
[dependencies]
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "pwd"

View file

@ -17,8 +17,8 @@ path = "src/readlink.rs"
[dependencies]
clap = "2.33"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "readlink"

View file

@ -16,8 +16,8 @@ path = "src/realpath.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "realpath"

View file

@ -16,8 +16,8 @@ path = "src/relpath.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "relpath"

View file

@ -15,11 +15,11 @@ edition = "2018"
path = "src/rm.rs"
[dependencies]
getopts = "0.2.18"
clap = "2.33"
walkdir = "2.2.8"
remove_dir_all = "0.5.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "rm"

View file

@ -7,13 +7,14 @@
// spell-checker:ignore (ToDO) bitor ulong
extern crate getopts;
extern crate clap;
extern crate remove_dir_all;
extern crate walkdir;
#[macro_use]
extern crate uucore;
use clap::{App, Arg};
use remove_dir_all::remove_dir_all;
use std::collections::VecDeque;
use std::fs;
@ -40,83 +41,139 @@ struct Options {
verbose: bool,
}
static NAME: &str = "rm";
static ABOUT: &str = "Remove (unlink) the FILE(s)";
static VERSION: &str = env!("CARGO_PKG_VERSION");
static OPT_DIR: &str = "dir";
static OPT_INTERACTIVE: &str = "interactive";
static OPT_FORCE: &str = "force";
static OPT_NO_PRESERVE_ROOT: &str = "no-preserve-root";
static OPT_ONE_FILE_SYSTEM: &str = "one-file-system";
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_VERBOSE: &str = "verbose";
static ARG_FILES: &str = "files";
fn get_usage() -> String {
format!("{0} [OPTION]... FILE...", executable!())
}
fn get_long_usage() -> String {
String::from(
"By default, rm does not remove directories. Use the --recursive (-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',
use one of these commands:
rm -- -foo
rm ./-foo
Note that if you use rm to remove a file, it might be possible to recover
some of its contents, given sufficient expertise and/or time. For greater
assurance that the contents are truly unrecoverable, consider using shred.",
)
}
pub fn uumain(args: impl uucore::Args) -> i32 {
let args = args.collect_str();
let usage = get_usage();
let long_usage = get_long_usage();
let matches = App::new(executable!())
.version(VERSION)
.about(ABOUT)
.usage(&usage[..])
.after_help(&long_usage[..])
// TODO: make getopts support -R in addition to -r
let mut opts = getopts::Options::new();
opts.optflag(
"f",
"force",
"ignore nonexistent files and arguments, never prompt",
);
opts.optflag("i", "", "prompt before every removal");
opts.optflag("I", "", "prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving some protection against most mistakes");
opts.optflagopt(
"",
"interactive",
"prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompts always",
"WHEN",
);
opts.optflag("", "one-file-system", "when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument (NOT IMPLEMENTED)");
opts.optflag("", "no-preserve-root", "do not treat '/' specially");
opts.optflag("", "preserve-root", "do not remove '/' (default)");
opts.optflag(
"r",
"recursive",
"remove directories and their contents recursively",
);
opts.optflag("d", "dir", "remove empty directories");
opts.optflag("v", "verbose", "explain what is being done");
opts.optflag("h", "help", "display this help and exit");
opts.optflag("V", "version", "output version information and exit");
.arg(
Arg::with_name(OPT_FORCE)
.short("f")
.long(OPT_FORCE)
.help("ignore nonexistent files and arguments, never prompt")
)
.arg(
Arg::with_name(OPT_PROMPT)
.short("i")
.long("prompt before every removal")
)
.arg(
Arg::with_name(OPT_PROMPT_MORE)
.short("I")
.help("prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving some protection against most mistakes")
)
.arg(
Arg::with_name(OPT_INTERACTIVE)
.long(OPT_INTERACTIVE)
.help("prompt according to WHEN: never, once (-I), or always (-i). Without WHEN, prompts always")
.value_name("WHEN")
.takes_value(true)
)
.arg(
Arg::with_name(OPT_ONE_FILE_SYSTEM)
.long(OPT_ONE_FILE_SYSTEM)
.help("when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument (NOT IMPLEMENTED)")
)
.arg(
Arg::with_name(OPT_NO_PRESERVE_ROOT)
.long(OPT_NO_PRESERVE_ROOT)
.help("do not treat '/' specially")
)
.arg(
Arg::with_name(OPT_PRESERVE_ROOT)
.long(OPT_PRESERVE_ROOT)
.help("do not remove '/' (default)")
)
.arg(
Arg::with_name(OPT_RECURSIVE).short("r")
.long(OPT_RECURSIVE)
.help("remove directories and their contents recursively")
)
.arg(
Arg::with_name(OPT_DIR)
.short("d")
.long(OPT_DIR)
.help("remove empty directories")
)
.arg(
Arg::with_name(OPT_VERBOSE)
.short("v")
.long(OPT_VERBOSE)
.help("explain what is being done")
)
.arg(
Arg::with_name(ARG_FILES)
.multiple(true)
.takes_value(true)
.min_values(1)
)
.get_matches_from(args);
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(f) => crash!(1, "{}", f),
};
let files: Vec<String> = matches
.values_of(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default();
let force = matches.opt_present("force");
let force = matches.is_present(OPT_FORCE);
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!();
println!("Usage:");
println!(" {0} [OPTION]... [FILE]...", NAME);
println!();
println!("{}", opts.usage("Remove (unlink) the FILE(s)."));
println!("By default, rm does not remove directories. Use the --recursive (-r)");
println!("option to remove each listed directory, too, along with all of its contents");
println!();
println!("To remove a file whose name starts with a '-', for example '-foo',");
println!("use one of these commands:");
println!("rm -- -foo");
println!();
println!("rm ./-foo");
println!();
println!("Note that if you use rm to remove a file, it might be possible to recover");
println!("some of its contents, given sufficient expertise and/or time. For greater");
println!("assurance that the contents are truly unrecoverable, consider using shred.");
} else if matches.opt_present("version") {
println!("{} {}", NAME, VERSION);
} else if matches.free.is_empty() && !force {
if files.is_empty() && !force {
// Still check by hand and not use clap
// Because "rm -f" is a thing
show_error!("missing an argument");
show_error!("for help, try '{0} --help'", NAME);
show_error!("for help, try '{0} --help'", executable!());
return 1;
} else {
let options = Options {
force,
interactive: {
if matches.opt_present("i") {
if matches.is_present(OPT_PROMPT) {
InteractiveMode::Always
} else if matches.opt_present("I") {
} else if matches.is_present(OPT_PROMPT_MORE) {
InteractiveMode::Once
} else if matches.opt_present("interactive") {
match &matches.opt_str("interactive").unwrap()[..] {
} else if matches.is_present(OPT_INTERACTIVE) {
match &matches.value_of(OPT_INTERACTIVE).unwrap()[..] {
"none" => InteractiveMode::None,
"once" => InteractiveMode::Once,
"always" => InteractiveMode::Always,
@ -126,15 +183,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
InteractiveMode::None
}
},
one_fs: matches.opt_present("one-file-system"),
preserve_root: !matches.opt_present("no-preserve-root"),
recursive: matches.opt_present("recursive"),
dir: matches.opt_present("dir"),
verbose: matches.opt_present("verbose"),
one_fs: matches.is_present(OPT_ONE_FILE_SYSTEM),
preserve_root: !matches.is_present(OPT_NO_PRESERVE_ROOT),
recursive: matches.is_present(OPT_RECURSIVE),
dir: matches.is_present(OPT_DIR),
verbose: matches.is_present(OPT_VERBOSE),
};
if options.interactive == InteractiveMode::Once
&& (options.recursive || matches.free.len() > 3)
{
if options.interactive == InteractiveMode::Once && (options.recursive || files.len() > 3) {
let msg = if options.recursive {
"Remove all arguments recursively? "
} else {
@ -145,7 +200,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
}
}
if remove(matches.free, options) {
if remove(files, options) {
return 1;
}
}

View file

@ -16,8 +16,8 @@ path = "src/rmdir.rs"
[dependencies]
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "rmdir"

View file

@ -16,8 +16,8 @@ path = "src/seq.rs"
[dependencies]
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "seq"

View file

@ -20,8 +20,8 @@ getopts = "0.2.18"
libc = "0.2.42"
rand = "0.5"
time = "0.1.40"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "shred"

View file

@ -17,8 +17,8 @@ path = "src/shuf.rs"
[dependencies]
getopts = "0.2.18"
rand = "0.5"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "shuf"

View file

@ -16,8 +16,8 @@ path = "src/sleep.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["parse_time"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["parse_time"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "sleep"

View file

@ -18,8 +18,8 @@ path = "src/sort.rs"
clap = "2.33"
itertools = "0.8.0"
semver = "0.9.0"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "sort"

View file

@ -16,8 +16,8 @@ path = "src/split.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "split"

View file

@ -17,8 +17,8 @@ path = "src/stat.rs"
[dependencies]
clap = "2.33"
time = "0.1.40"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "libc"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["entries", "libc"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "stat"

View file

@ -17,8 +17,8 @@ path = "src/stdbuf.rs"
[dependencies]
getopts = "0.2.18"
tempfile = "3.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[build-dependencies]
libstdbuf = { version="0.0.1", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" }

View file

@ -19,8 +19,8 @@ crate-type = ["cdylib", "rlib"] # XXX: note: the rlib is just to prevent Cargo f
[dependencies]
cpp = "0.4"
libc = "0.2"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../../../uucore_procs" }
[build-dependencies]
cpp_build = "0.4"

View file

@ -16,8 +16,8 @@ path = "src/sum.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "sum"

View file

@ -15,10 +15,10 @@ edition = "2018"
path = "src/sync.rs"
[dependencies]
getopts = "0.2.18"
clap = "2.33"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["wide"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["wide"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] }
[[bin]]

View file

@ -7,17 +7,14 @@
/* Last synced with: sync (GNU coreutils) 8.13 */
extern crate getopts;
extern crate clap;
extern crate libc;
#[cfg(windows)]
#[macro_use]
extern crate uucore;
#[cfg(not(windows))]
extern crate uucore;
static NAME: &str = "sync";
use clap::App;
static ABOUT: &str = "Synchronize cached writes to persistent storage";
static VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(unix)]
@ -118,57 +115,23 @@ mod platform {
}
}
fn get_usage() -> String {
format!("{0} [OPTION]... FILE...", executable!())
}
pub fn uumain(args: impl uucore::Args) -> i32 {
let args = args.collect_str();
let usage = get_usage();
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,
_ => {
help(&opts);
return 1;
}
};
if matches.opt_present("h") {
help(&opts);
return 0;
}
if matches.opt_present("V") {
version();
return 0;
}
let _matches = App::new(executable!())
.version(VERSION)
.about(ABOUT)
.usage(&usage[..])
.get_matches_from(args);
sync();
0
}
fn version() {
println!("{} (uutils) {}", NAME, VERSION);
println!("The MIT License");
println!();
println!("Author -- Alexander Fomin.");
}
fn help(opts: &getopts::Options) {
let msg = format!(
"{0} {1}
Usage:
{0} [OPTION]
Force changed blocks to disk, update the super block.",
NAME, VERSION
);
print!("{}", opts.usage(&msg));
}
fn sync() -> isize {
unsafe { platform::do_sync() }
}

View file

@ -16,8 +16,8 @@ path = "src/tac.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tac"

View file

@ -17,8 +17,8 @@ path = "src/tail.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] }
[target.'cfg(target_os = "redox")'.dependencies]

View file

@ -17,8 +17,8 @@ path = "src/tee.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tee"

View file

@ -16,8 +16,8 @@ path = "src/test.rs"
[dependencies]
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"

View file

@ -18,8 +18,8 @@ path = "src/timeout.rs"
getopts = "0.2.18"
libc = "0.2.42"
time = "0.1.40"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["parse_time", "process", "signals"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["parse_time", "process", "signals"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "timeout"

View file

@ -18,8 +18,8 @@ path = "src/touch.rs"
filetime = "0.2.1"
getopts = "0.2.18"
time = "0.1.40"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["libc"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["libc"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "touch"

View file

@ -18,8 +18,8 @@ path = "src/tr.rs"
bit-set = "0.5.0"
fnv = "1.0.5"
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tr"

View file

@ -15,8 +15,8 @@ edition = "2018"
path = "src/true.rs"
[dependencies]
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "true"

View file

@ -16,8 +16,8 @@ path = "src/truncate.rs"
[dependencies]
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "truncate"

View file

@ -16,8 +16,8 @@ path = "src/tsort.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tsort"

View file

@ -17,8 +17,8 @@ path = "src/tty.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tty"

View file

@ -17,8 +17,8 @@ path = "src/uname.rs"
[dependencies]
clap = "2.32"
platform-info = "0.0.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "uname"

View file

@ -17,8 +17,8 @@ path = "src/unexpand.rs"
[dependencies]
getopts = "0.2.18"
unicode-width = "0.1.5"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "unexpand"

View file

@ -16,8 +16,8 @@ path = "src/uniq.rs"
[dependencies]
getopts = "0.2.18"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "uniq"

View file

@ -17,8 +17,8 @@ path = "src/unlink.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "unlink"

View file

@ -19,8 +19,8 @@ getopts = "0.2.18"
time = "0.1.40"
chrono = "0.4"
clap = "2.32"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["libc", "utmpx"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["libc", "utmpx"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "uptime"

View file

@ -16,8 +16,8 @@ path = "src/users.rs"
[dependencies]
clap = "2.33"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["utmpx"] }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore = { version=">=0.0.4", package="uucore", path="../../uucore", features=["utmpx"] }
uucore_procs = { version=">=0.0.4", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "users"

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