1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge branch 'master' into expr-regex

This commit is contained in:
Ian Douglas Scott 2017-10-01 10:06:28 -07:00
commit 1a28a48ca3
No known key found for this signature in database
GPG key ID: 4924E10E199B5959
100 changed files with 2193 additions and 814 deletions

253
Cargo.lock generated
View file

@ -37,7 +37,7 @@ dependencies = [
"install 0.0.1",
"kill 0.0.1",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"link 0.0.1",
"ln 0.0.1",
"logname 0.0.1",
@ -82,7 +82,7 @@ dependencies = [
"tee 0.0.1",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"test 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"timeout 0.0.1",
"touch 0.0.1",
"tr 0.0.1",
@ -140,7 +140,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -150,7 +150,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -200,7 +200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "1.0.0"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -212,9 +212,14 @@ dependencies = [
"uucore 0.0.1",
]
[[package]]
name = "cc"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -229,7 +234,7 @@ dependencies = [
name = "chmod"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
"walker 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -248,8 +253,8 @@ name = "chrono"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -264,7 +269,7 @@ dependencies = [
name = "cksum"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -286,10 +291,10 @@ dependencies = [
[[package]]
name = "cmake"
version = "0.1.24"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -297,7 +302,7 @@ name = "comm"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -305,9 +310,17 @@ dependencies = [
name = "cp"
version = "0.0.1"
dependencies = [
"clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"ioctl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
"walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"xattr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -343,7 +356,7 @@ dependencies = [
name = "dirname"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -351,7 +364,7 @@ dependencies = [
name = "du"
version = "0.0.1"
dependencies = [
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -371,7 +384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "env"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -388,8 +401,8 @@ dependencies = [
name = "expr"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"onig 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"onig 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -410,14 +423,14 @@ name = "filetime"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fmt"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -466,7 +479,7 @@ name = "hashsum"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
@ -478,7 +491,7 @@ dependencies = [
name = "head"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -486,7 +499,7 @@ dependencies = [
name = "hostid"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -494,7 +507,7 @@ dependencies = [
name = "hostname"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -510,10 +523,15 @@ name = "install"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
[[package]]
name = "ioctl-sys"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "itertools"
version = "0.6.0"
@ -535,7 +553,7 @@ dependencies = [
name = "kill"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -546,19 +564,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.24"
source = "git+https://github.com/rust-lang/libc.git#83f5543e761bad58c1f061447c28df4a0201c761"
version = "0.2.26"
source = "git+https://github.com/rust-lang/libc.git#c43c0770db6b85ade0b70009464603ff9be4b37d"
[[package]]
name = "libc"
version = "0.2.24"
version = "0.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "link"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -566,7 +584,7 @@ dependencies = [
name = "ln"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -574,7 +592,7 @@ dependencies = [
name = "logname"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -587,7 +605,7 @@ dependencies = [
"pretty-bytes 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"term_grid 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"termsize 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -597,7 +615,7 @@ name = "memchr"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -605,7 +623,7 @@ name = "mkdir"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -614,7 +632,7 @@ name = "mkfifo"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -623,7 +641,7 @@ name = "mknod"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -659,7 +677,7 @@ name = "nice"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -669,8 +687,8 @@ 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.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -680,7 +698,7 @@ version = "0.0.1"
dependencies = [
"aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -692,7 +710,7 @@ name = "nohup"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -701,41 +719,41 @@ name = "nproc"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
[[package]]
name = "num"
version = "0.1.39"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-integer"
version = "0.1.34"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-iter"
version = "0.1.33"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.1.39"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -743,38 +761,38 @@ name = "num_cpus"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "od"
version = "0.0.1"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
[[package]]
name = "onig"
version = "1.3.0"
version = "1.6.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)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"onig_sys 63.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"onig_sys 65.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "onig_sys"
version = "63.0.2"
version = "65.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cmake 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -791,7 +809,7 @@ name = "pathchk"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -813,7 +831,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -838,7 +856,7 @@ version = "0.0.1"
dependencies = [
"aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -863,7 +881,7 @@ name = "rand"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -871,7 +889,7 @@ name = "readlink"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -885,7 +903,7 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.1.19"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -913,12 +931,23 @@ dependencies = [
"uucore 0.0.1",
]
[[package]]
name = "remove_dir_all"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rm"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
"walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -935,10 +964,10 @@ version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -995,9 +1024,9 @@ version = "0.0.1"
dependencies = [
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1041,7 +1070,7 @@ name = "stat"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1072,7 +1101,7 @@ version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1091,7 +1120,7 @@ version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1101,7 +1130,7 @@ name = "tee"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1119,7 +1148,7 @@ version = "2.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1139,7 +1168,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1150,7 +1179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1158,7 +1187,7 @@ dependencies = [
name = "test"
version = "0.0.1"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1182,12 +1211,12 @@ dependencies = [
[[package]]
name = "time"
version = "0.1.37"
version = "0.1.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1196,8 +1225,8 @@ name = "timeout"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1207,7 +1236,7 @@ version = "0.0.1"
dependencies = [
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1246,7 +1275,7 @@ name = "tty"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1294,8 +1323,8 @@ name = "unix_socket"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1303,7 +1332,7 @@ name = "unlink"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
@ -1342,8 +1371,8 @@ version = "0.0.1"
dependencies = [
"data-encoding 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (git+https://github.com/rust-lang/libc.git)",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.26 (git+https://github.com/rust-lang/libc.git)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1415,6 +1444,14 @@ name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "xattr"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "yes"
version = "0.0.1"
@ -1433,11 +1470,12 @@ dependencies = [
"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
"checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
"checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d"
"checksum cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7db2f146208d7e0fbee761b09cd65a7f51ccc38705d4e7262dad4d73b12a76b1"
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9"
"checksum clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "867a885995b4184be051b70a592d4d70e32d7a188db6e8dff626af286a962771"
"checksum cmake 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ebbb35d3dc9cd09497168f33de1acb79b265d350ab0ac34133b98f8509af1f"
"checksum cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "357c07e7a1fc95732793c1edb5901e1a1f305cfcf63a90eb12dbd22bdb6b789d"
"checksum data-encoding 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d867ddbf09de0b73e09ec798972fb7f870495a0893f6f736c1855448c5a56789"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
@ -1446,27 +1484,29 @@ dependencies = [
"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d68db75012a85555434ee079e7e6337931f87a087ab2988becbadf64673a7f"
"checksum ioctl-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e2c4b26352496eaaa8ca7cfa9bd99e93419d3f7983dc6e99c2a35fe9e33504a"
"checksum itertools 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "772a0928a97246167d59a2a4729df5871f1327ab8b36fd24c4224b229cb47b99"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
"checksum libc 0.2.24 (git+https://github.com/rust-lang/libc.git)" = "<none>"
"checksum libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)" = "38f5c2b18a287cf78b4097db62e20f43cace381dc76ae5c0a3073067f78b7ddc"
"checksum libc 0.2.26 (git+https://github.com/rust-lang/libc.git)" = "<none>"
"checksum libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "30885bcb161cf67054244d10d4a7f4835ffd58773bc72e07d35fecf472295503"
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
"checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487"
"checksum num 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "2c3a3dc9f30bf824141521b30c908a859ab190b76e20435fcd89f35eb6583887"
"checksum num-integer 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "ef1a4bf6f9174aa5783a9b4cc892cacd11aebad6c69ad027a0b65c6ca5f8aa37"
"checksum num-iter 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d1891bd7b936f12349b7d1403761c8a0b85a18b148e9da4429d5d102c1a41e"
"checksum num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "1708c0628602a98b52fad936cf3edb9a107af06e52e49fdf0707e884456a6af6"
"checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525"
"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01"
"checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0"
"checksum num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aec53c34f2d0247c5ca5d32cca1478762f301740468ee9ee6dcb7a0dd7a0c584"
"checksum onig 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee619da9cf707b167098e84fb00f10db61d5a662d1d29b59822bcac3a81553dd"
"checksum onig_sys 63.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "531682ab45a2cd40eff91f29340dae975f25336d2b61e624adabed39e61d7fb3"
"checksum onig 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1271a3f93197303deda8aedcd96ed2dbb908f61c0954ae70bf7a42f536dc35d7"
"checksum onig_sys 65.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fbdee58fb75f5b7749ebc8f601f570961eed595dfe4c2bb9a542e2f7ae20b946"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum pretty-bytes 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3095b93999fae14b4e0bb661c53875a441d9058b7b1a7ba2dfebc104d3776349"
"checksum quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c36987d4978eb1be2e422b1e0423a557923a5c3e7e6f31d5699e9aafaefa469"
"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
"checksum redox_syscall 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "e4a357d14a12e90a37d658725df0e6468504750b5948b9710f83f94a0c5818e8"
"checksum redox_syscall 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "9df6a71a1e67be2104410736b2389fb8e383c1d7e9e792d629ff13c02867147a"
"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
"checksum remove_dir_all 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0882bc41b0ba6131c7f0ce97233b62d8099e3f3abc60d4938185d3e35439c0cc"
"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
@ -1482,7 +1522,7 @@ dependencies = [
"checksum termsize 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3a225cb94c3630aabd2e289cad545679dd38b5f4891524e92da1be10aae6e4e8"
"checksum textwrap 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f86300c3e7416ee233abd7cda890c492007a3980f941f79185c753a701257167"
"checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14"
"checksum time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd7ccbf969a892bf83f1e441126968a07a3941c24ff522a26af9f9f4585d1a3"
"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
"checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unindent 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3508be0ce1bacc38d579b69bffb4b8d469f5af0c388ff4890b2b294e61671ffe"
@ -1496,3 +1536,4 @@ dependencies = [
"checksum walker 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0488b82b198ac3588ba688f5e56cbd53e0b6dad64f075e67c15647e54aac610"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum xattr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb373b92de38a4301d66bec009929b4fb83120ea1c4a401be89dbe0b9777443"

View file

@ -238,17 +238,17 @@ whoami = { optional=true, path="src/whoami" }
yes = { optional=true, path="src/yes" }
[dev-dependencies]
time = "*"
filetime = "*"
libc = "*"
regex="*"
rand="*"
tempdir="*"
unindent="*"
lazy_static = "*"
time = "0.1.38"
filetime = "0.1.10"
libc = "0.2.26"
regex = "0.2.2"
rand = "0.3.15"
tempdir = "0.3.5"
unindent = "0.1.0"
lazy_static = "0.2.2"
[target.'cfg(unix)'.dev-dependencies]
unix_socket = "*"
unix_socket = "0.5.0"
[[bin]]
name = "uutils"

193
README.md
View file

@ -4,6 +4,7 @@ uutils coreutils
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uutils/coreutils/blob/master/LICENSE)
[![Build Status](https://api.travis-ci.org/uutils/coreutils.svg?branch=master)](https://travis-ci.org/uutils/coreutils)
[![Build status](https://ci.appveyor.com/api/projects/status/787ltcxgy86r20le?svg=true)](https://ci.appveyor.com/project/Arcterus/coreutils)
[![LOC](https://tokei.rs/b1/github/uutils/coreutils?category=code)](https://github.com/Aaronepower/tokei)
uutils is an attempt at writing universal (as in cross-platform) CLI
utils in [Rust](http://www.rust-lang.org). This repo is to aggregate the GNU
@ -144,110 +145,96 @@ Contribute
To contribute to coreutils, please see [CONTRIBUTING](CONTRIBUTING.md).
To do
-----
Utilities
---------
* [x] arch
* [x] base32
* [x] base64
* [x] basename
* [x] cat
* [ ] chcon
* [x] chgrp
* [x] chmod
* [x] chown
* [x] chroot
* [x] cksum
* [x] comm
* [ ] cp (not much done)
* [ ] csplit
* [x] cut
* [ ] date
* [ ] dd
* [ ] df
* [x] dircolors
* [x] dirname
* [x] du
* [x] echo
* [x] env
* [x] expand
* [x] expr
* [x] factor
* [x] false
* [x] fmt
* [x] fold
* [x] groups
* [x] hashsum
* [x] head
* [x] hostid
* [x] hostname
* [x] id
* [ ] install (a couple of missing options)
* [ ] join
* [x] kill
* [x] link
* [x] ln
* [x] logname
* [ ] ls
* [x] ~~md5sum~~, ~~sha1sum~~, ~~sha224sum~~, ~~sha256sum~~, ~~sha384sum~~, ~~sha512sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs))
* [x] mkdir
* [x] mkfifo
* [x] mknod
* [x] mktemp
* [x] mv
* [ ] more (in progress, needs lots of work)
* [x] nice
* [x] nl
* [x] nohup
* [x] nproc
* [ ] numfmt
* [ ] od (almost complete, `--strings` and 128-bit datatypes are missing)
* [x] paste
* [x] pathchk
* [x] pinky
* [ ] pr
* [x] printenv
* [ ] printf
* [x] ptx
* [x] pwd
* [x] readlink
* [x] realpath
* [x] relpath
* [x] rm
* [x] rmdir
* [ ] runcon
* [x] seq
* [x] shred
* [x] shuf
* [x] sleep
* [ ] sort (a couple of options implemented)
* [ ] split (a couple of missing options)
* [x] stat
* [x] stdbuf
* [ ] stty
* [x] sum
* [x] sync
* [x] tac
* [ ] tail (not all features implemented)
* [x] tee
* [ ] test (not all features implemented)
* [x] timeout
* [x] touch
* [x] tr
* [x] true
* [x] truncate
* [x] tsort
* [x] tty
* [x] uname
* [x] unexpand
* [x] uniq
* [x] unlink
* [x] uptime
* [x] users
* [x] wc
* [x] who
* [x] whoami
* [x] yes
| Done | Semi-Done | To Do |
|-----------|-----------|--------|
| arch | cp | chcon |
| base32 | expr | csplit |
| base64 | install | dd |
| basename | ls | df |
| cat | more | join |
| chgrp | od (`--strings` and 128-bit data types missing) | numfmt |
| chmod | printf | pr |
| chown | sort | runcon |
| chroot | split | stty |
| cksum | tail | |
| comm | test | |
| cut | date | |
| dircolors | | |
| dirname | | |
| du | | |
| echo | | |
| env | | |
| expand | | |
| factor | | |
| false | | |
| fmt | | |
| fold | | |
| groups | | |
| hashsum | | |
| head | | |
| hostid | | |
| hostname | | |
| id | | |
| kill | | |
| link | | |
| ln | | |
| logname | | |
| ~~md5sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs)) | |
| ~~sha1sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs)) | |
| ~~sha224sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs)) | |
| ~~sha256sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs)) | |
| ~~sha384sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs)) | |
| ~~sha512sum~~ (replaced by [hashsum](https://github.com/uutils/coreutils/blob/master/src/hashsum/hashsum.rs)) | |
| mkdir | | |
| mkfifo | | |
| mknod | | |
| mktemp | | |
| mv | | |
| nice | | |
| nl | | |
| nohup | | |
| nproc | | |
| paste | | |
| pathchk | | |
| pinky | | |
| printenv | | |
| ptx | | |
| pwd | | |
| readlink | | |
| realpath | | |
| relpath | | |
| rm | | |
| rmdir | | |
| seq | | |
| shred | | |
| shuf | | |
| sleep | | |
| stat | | |
| stdbuf | | |
| sum | | |
| sync | | |
| tac | | |
| tee | | |
| timeout | | |
| touch | | |
| tr | | |
| true | | |
| truncate | | |
| tsort | | |
| tty | | |
| uname | | |
| unexpand | | |
| uniq | | |
| unlink | | |
| uptime | | |
| users | | |
| wc | | |
| who | | |
| whoami | | |
| yes | | |
License
-------

View file

@ -11,7 +11,7 @@ path = "base32.rs"
uucore = { path="../uucore" }
[dependencies.clippy]
version = "*"
version = "0.0.143"
optional = true
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_chgrp"
path = "chgrp.rs"
[dependencies]
walkdir = "*"
walkdir = "1.0.7"
[dependencies.uucore]
path = "../uucore"

View file

@ -8,9 +8,9 @@ name = "uu_chmod"
path = "chmod.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
walker = "*"
walker = "1.0.0"
[[bin]]
name = "chmod"

View file

@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/
#[cfg(unix)]
extern crate libc;
extern crate walker;
@ -16,9 +17,9 @@ extern crate walker;
extern crate uucore;
use std::error::Error;
use std::ffi::CString;
use std::io::{self, Write};
use std::mem;
use std::fs;
use std::io::Write;
use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::Path;
use walker::Walker;
@ -74,16 +75,10 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
let verbose = matches.opt_present("verbose");
let preserve_root = matches.opt_present("preserve-root");
let recursive = matches.opt_present("recursive");
let fmode = matches.opt_str("reference").and_then(|fref| {
let s = CString::new(fref).unwrap_or_else( |_| {
crash!(1, "reference file name contains internal nul byte")
});
let mut stat : libc::stat = unsafe { mem::uninitialized() };
let statres = unsafe { libc::stat(s.as_ptr() as *const _, &mut stat as *mut libc::stat) };
if statres == 0 {
Some(stat.st_mode)
} else {
crash!(1, "cannot stat attribues of '{}': {}", matches.opt_str("reference").unwrap(), io::Error::last_os_error())
let fmode = matches.opt_str("reference").and_then(|ref fref| {
match fs::metadata(fref) {
Ok(meta) => Some(meta.mode()),
Err(err) => crash!(1, "cannot stat attribues of '{}': {}", fref, err)
}
});
let cmode =
@ -108,7 +103,7 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
0
}
fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), i32> {
fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option<u32>, cmode: Option<&String>) -> Result<(), i32> {
let mut r = Ok(());
for filename in &files {
@ -157,28 +152,25 @@ fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve
}
#[cfg(windows)]
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), i32> {
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<u32>, cmode: Option<&String>) -> Result<(), i32> {
// chmod is useless on Windows
// it doesn't set any permissions at all
// instead it just sets the readonly attribute on the file
Err(0)
}
#[cfg(unix)]
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), i32> {
let path = CString::new(name).unwrap_or_else(|e| panic!("{}", e));
let mut stat: libc::stat = unsafe { mem::uninitialized() };
let statres = unsafe { libc::stat(path.as_ptr(), &mut stat as *mut libc::stat) };
let mut fperm =
if statres == 0 {
stat.st_mode & 0o7777
} else {
#[cfg(any(unix, target_os = "redox"))]
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<u32>, cmode: Option<&String>) -> Result<(), i32> {
let mut fperm = match fs::metadata(name) {
Ok(meta) => meta.mode() & 0o7777,
Err(err) => {
if !quiet {
show_error!("{}", io::Error::last_os_error());
show_error!("{}", err);
}
return Err(1);
};
}
};
match fmode {
Some(mode) => try!(change_file(fperm, mode, file, &path, verbose, changes, quiet)),
Some(mode) => try!(change_file(fperm, mode, file, name, verbose, changes, quiet)),
None => {
for mode in cmode.unwrap().split(',') { // cmode is guaranteed to be Some in this case
let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
@ -190,7 +182,7 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
};
match result {
Ok(mode) => {
try!(change_file(fperm, mode, file, &path, verbose, changes, quiet));
try!(change_file(fperm, mode, file, name, verbose, changes, quiet));
fperm = mode;
}
Err(f) => {
@ -207,13 +199,13 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
Ok(())
}
fn parse_numeric(fperm: libc::mode_t, mut mode: &str) -> Result<libc::mode_t, String> {
fn parse_numeric(fperm: u32, mut mode: &str) -> Result<u32, String> {
let (op, pos) = try!(parse_op(mode, Some('=')));
mode = mode[pos..].trim_left_matches('0');
if mode.len() > 4 {
Err(format!("mode is too large ({} > 7777)", mode))
} else {
match libc::mode_t::from_str_radix(mode, 8) {
match u32::from_str_radix(mode, 8) {
Ok(change) => {
Ok(match op {
'+' => fperm | change,
@ -227,14 +219,23 @@ fn parse_numeric(fperm: libc::mode_t, mut mode: &str) -> Result<libc::mode_t, St
}
}
fn parse_symbolic(mut fperm: libc::mode_t, mut mode: &str, file: &Path) -> Result<libc::mode_t, String> {
fn parse_symbolic(mut fperm: u32, mut mode: &str, file: &Path) -> Result<u32, String> {
#[cfg(unix)]
use libc::umask;
#[cfg(target_os = "redox")]
unsafe fn umask(_mask: u32) -> u32 {
// XXX Redox does not currently have umask
0
}
let (mask, pos) = parse_levels(mode);
if pos == mode.len() {
return Err(format!("invalid mode ({})", mode));
}
let respect_umask = pos == 0;
let last_umask = unsafe {
libc::umask(0)
umask(0)
};
mode = &mode[pos..];
while mode.len() > 0 {
@ -242,7 +243,7 @@ fn parse_symbolic(mut fperm: libc::mode_t, mut mode: &str, file: &Path) -> Resul
mode = &mode[pos..];
let (mut srwx, pos) = parse_change(mode, fperm, file);
if respect_umask {
srwx &= !last_umask;
srwx &= !(last_umask as u32);
}
mode = &mode[pos..];
match op {
@ -253,12 +254,12 @@ fn parse_symbolic(mut fperm: libc::mode_t, mut mode: &str, file: &Path) -> Resul
}
}
unsafe {
libc::umask(last_umask);
umask(last_umask);
}
Ok(fperm)
}
fn parse_levels(mode: &str) -> (libc::mode_t, usize) {
fn parse_levels(mode: &str) -> (u32, usize) {
let mut mask = 0;
let mut pos = 0;
for ch in mode.chars() {
@ -290,7 +291,7 @@ fn parse_op(mode: &str, default: Option<char>) -> Result<(char, usize), String>
}
}
fn parse_change(mode: &str, fperm: libc::mode_t, file: &Path) -> (libc::mode_t, usize) {
fn parse_change(mode: &str, fperm: u32, file: &Path) -> (u32, usize) {
let mut srwx = fperm & 0o7000;
let mut pos = 0;
for ch in mode.chars() {
@ -318,24 +319,24 @@ fn parse_change(mode: &str, fperm: libc::mode_t, file: &Path) -> (libc::mode_t,
(srwx, pos)
}
fn change_file(fperm: libc::mode_t, mode: libc::mode_t, file: &Path, path: &CString, verbose: bool, changes: bool, quiet: bool) -> Result<(), i32> {
fn change_file(fperm: u32, mode: u32, file: &Path, path: &str, verbose: bool, changes: bool, quiet: bool) -> Result<(), i32> {
if fperm == mode {
if verbose && !changes {
show_info!("mode of '{}' retained as {:o}", file.display(), fperm);
}
Ok(())
} else if unsafe { libc::chmod(path.as_ptr(), mode) } == 0 {
if verbose || changes {
show_info!("mode of '{}' changed from {:o} to {:o}", file.display(), fperm, mode);
}
Ok(())
} else {
} else if let Err(err) = fs::set_permissions(Path::new(path), fs::Permissions::from_mode(mode)) {
if !quiet {
show_error!("{}", io::Error::last_os_error());
show_error!("{}", err);
}
if verbose {
show_info!("failed to change mode of file '{}' from {:o} to {:o}", file.display(), fperm, mode);
}
return Err(1);
Err(1)
} else {
if verbose || changes {
show_info!("mode of '{}' changed from {:o} to {:o}", file.display(), fperm, mode);
}
Ok(())
}
}

View file

@ -8,7 +8,7 @@ name = "uu_chown"
path = "chown.rs"
[dependencies]
glob = "*"
glob = "0.2.11"
walkdir = "0.1"
[dependencies.uucore]
@ -17,7 +17,7 @@ default-features = false
features = ["entries", "fs"]
[dependencies.clippy]
version = "*"
version = "0.0.143"
optional = true
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_chroot"
path = "chroot.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
[dependencies.uucore]
path = "../uucore"

View file

@ -8,7 +8,7 @@ name = "uu_cksum"
path = "cksum.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_comm"
path = "comm.rs"
[dependencies]
libc = "*"
getopts = "*"
libc = "0.2.26"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -1,16 +1,33 @@
[package]
name = "cp"
version = "0.0.1"
authors = []
authors = [
"Jordy Dickinson <jordy.dickinson@gmail.com>",
"Joshua S. Miller <jsmiller@uchicago.edu>",
]
[lib]
name = "uu_cp"
path = "cp.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
walkdir = "1.0.7"
clap = "2.20.0"
quick-error = "1.1.0"
uucore = { path="../uucore" }
filetime = "0.1"
[target.'cfg(target_os = "linux")'.dependencies]
ioctl-sys = "0.5.2"
[target.'cfg(target_os = "windows")'.dependencies]
kernel32-sys = "*"
winapi = "*"
[target.'cfg(unix)'.dependencies]
xattr="0.2.1"
[[bin]]
name = "cp"

38
src/cp/README.md Normal file
View file

@ -0,0 +1,38 @@
## Feature list
### To Do
- [ ] archive
- [ ] attributes-only
- [ ] copy-contents
- [ ] no-dereference-preserve-linkgs
- [ ] dereference
- [ ] no-dereference
- [ ] preserve-default-attributes
- [ ] preserve
- [ ] no-preserve
- [ ] parents
- [ ] reflink
- [ ] sparse
- [ ] strip-trailing-slashes
- [ ] update
- [ ] one-file-system
- [ ] context
- [ ] cli-symbolic-links
### Completed
- [x] backup
- [x] force (Not implemented on Windows)
- [x] interactive
- [x] link
- [x] no-clobber
- [x] no-target-directory
- [x] paths
- [x] recursive
- [x] remove-destination (On Windows, current only works for writeable files)
- [x] suffix
- [x] symbolic-link
- [x] target-directory
- [x] verbose
- [x] version

File diff suppressed because it is too large Load diff

View file

@ -8,8 +8,8 @@ name = "uu_date"
path = "date.rs"
[dependencies]
chrono = "0.4"
clap = "2.25"
chrono = "0.4.0"
clap = "2.24.1"
uucore = { path="../uucore" }
[[bin]]

View file

@ -1,4 +1,4 @@
extern crate uu_echo;
extern crate uu_date;
fn main() {
std::process::exit(uu_date::uumain(std::env::args().collect()));

View file

@ -8,7 +8,7 @@ name = "uu_dircolors"
path = "dircolors.rs"
[dependencies]
glob = "*"
glob = "0.2.11"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_dirname"
path = "dirname.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_du"
path = "du.rs"
[dependencies]
time = "*"
time = "0.1.38"
uucore = { path="../uucore" }
[[bin]]

2
src/env/Cargo.toml vendored
View file

@ -8,7 +8,7 @@ name = "uu_env"
path = "env.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_expand"
path = "expand.rs"
[dependencies]
unicode-width = "*"
getopts = "*"
unicode-width = "0.1.4"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_expr"
path = "expr.rs"
[dependencies]
libc = "*"
onig = "1.3"
libc = "0.2.26"
onig = "1.3.0"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_factor"
path = "factor.rs"
[dependencies]
rand = "*"
rand = "0.3.15"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_fmt"
path = "fmt.rs"
[dependencies]
libc = "*"
unicode-width = "*"
libc = "0.2.26"
unicode-width = "0.1.4"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,12 +8,12 @@ name = "uu_hashsum"
path = "hashsum.rs"
[dependencies]
getopts = "*"
libc = "*"
regex = "*"
regex-syntax = "*"
rust-crypto = "*"
rustc-serialize = "*"
getopts = "0.2.14"
libc = "0.2.26"
regex = "0.2.2"
regex-syntax = "0.4.1"
rust-crypto = "0.2.36"
rustc-serialize = "0.3.24"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_head"
path = "head.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_hostid"
path = "hostid.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_hostname"
path = "hostname.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,12 +8,12 @@ name = "uu_install"
path = "install.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
libc = ">= 0.2"
uucore = { path="../uucore" }
[dev-dependencies]
time = "*"
time = "0.1.38"
[[bin]]
name = "install"

View file

@ -27,12 +27,12 @@ static SUMMARY: &'static str = "Copy SOURCE to DEST or multiple SOURCE(s) to the
DIRECTORY, while setting permission modes and owner/group";
static LONG_HELP: &'static str = "";
const DEFAULT_MODE: libc::mode_t = 755;
const DEFAULT_MODE: u32 = 755;
#[allow(dead_code)]
pub struct Behaviour {
main_function: MainFunction,
specified_mode: Option<libc::mode_t>,
specified_mode: Option<u32>,
suffix: String,
verbose: bool
}
@ -47,7 +47,7 @@ pub enum MainFunction {
impl Behaviour {
/// Determine the mode for chmod after copy.
pub fn mode(&self) -> libc::mode_t {
pub fn mode(&self) -> u32 {
match self.specified_mode {
Some(x) => x,
None => DEFAULT_MODE
@ -138,8 +138,7 @@ fn parse_opts(args: Vec<String>) -> getopts::Matches {
DIRECTORY", "DIRECTORY")
// TODO implement flag
.optflag("T", "no-target-directory", "(unimplemented) treat DEST as a normal file")
// TODO implement flag
.optflag("v", "verbose", "(unimplemented) explain what is being done")
.optflag("v", "verbose", "explain what is being done")
// TODO implement flag
.optflag("P", "preserve-context", "(unimplemented) preserve security context")
// TODO implement flag
@ -181,8 +180,6 @@ fn check_unimplemented(matches: &getopts::Matches) -> Result<(), &str> {
Err("--target-directory, -t")
} else if matches.opt_present("no-target-directory") {
Err("--no-target-directory, -T")
} else if matches.opt_present("verbose") {
Err("--verbose, -v")
} else if matches.opt_present("preserve-context") {
Err("--preserve-context, -P")
} else if matches.opt_present("context") {
@ -209,7 +206,7 @@ fn behaviour(matches: &getopts::Matches) -> Result<Behaviour, i32> {
let considering_dir: bool = MainFunction::Directory == main_function;
let specified_mode: Option<libc::mode_t> = if matches.opt_present("mode") {
let specified_mode: Option<u32> = if matches.opt_present("mode") {
match matches.opt_str("mode") {
Some(x) => {
match mode::parse(&x[..], considering_dir) {
@ -367,7 +364,7 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<(), ()> {
}
if b.verbose {
print!("{} -> {}", from.display(), to.display());
show_info!("'{}' -> '{}'", from.display(), to.display());
}
Ok(())

View file

@ -2,9 +2,10 @@ extern crate libc;
use std::io::Write;
use std::path::Path;
use std::fs;
/// Takes a user-supplied string and tries to parse to u16 mode bitmask.
pub fn parse(mode_string: &str, considering_dir: bool) -> Result<libc::mode_t, String> {
pub fn parse(mode_string: &str, considering_dir: bool) -> Result<u32, String> {
let numbers: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
// Passing 000 as the existing permissions seems to mirror GNU behaviour.
@ -19,21 +20,12 @@ pub fn parse(mode_string: &str, considering_dir: bool) -> Result<libc::mode_t, S
///
/// Adapted from mkdir.rs. Handles own error printing.
///
#[cfg(unix)]
pub fn chmod(path: &Path, mode: libc::mode_t) -> Result<(), ()> {
use std::ffi::CString;
use std::io::Error;
let file = CString::new(path.as_os_str().to_str().unwrap()).
unwrap_or_else(|e| crash!(1, "{}", e));
let mode = mode as libc::mode_t;
if unsafe { libc::chmod(file.as_ptr(), mode) } != 0 {
show_info!("{}: chmod failed with errno {}", path.display(),
Error::last_os_error().raw_os_error().unwrap());
return Err(());
}
Ok(())
#[cfg(any(unix, target_os = "redox"))]
pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> {
use std::os::unix::fs::PermissionsExt;
fs::set_permissions(path, fs::Permissions::from_mode(mode)).map_err(|err| {
show_info!("{}: chmod failed with error {}", path.display(), err);
})
}
/// chmod a file or directory on Windows.
@ -41,7 +33,7 @@ pub fn chmod(path: &Path, mode: libc::mode_t) -> Result<(), ()> {
/// Adapted from mkdir.rs.
///
#[cfg(windows)]
pub fn chmod(path: &Path, mode: libc::mode_t) -> Result<(), ()> {
pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> {
// chmod on Windows only sets the readonly flag, which isn't even honored on directories
Ok(())
}
@ -53,13 +45,13 @@ pub fn chmod(path: &Path, mode: libc::mode_t) -> Result<(), ()> {
mod chmod_rs {
extern crate libc;
pub fn parse_numeric(fperm: libc::mode_t, mut mode: &str) -> Result<libc::mode_t, String> {
pub fn parse_numeric(fperm: u32, mut mode: &str) -> Result<u32, String> {
let (op, pos) = try!(parse_op(mode, Some('=')));
mode = mode[pos..].trim_left_matches('0');
if mode.len() > 4 {
Err(format!("mode is too large ({} > 7777)", mode))
} else {
match libc::mode_t::from_str_radix(mode, 8) {
match u32::from_str_radix(mode, 8) {
Ok(change) => {
Ok(match op {
'+' => fperm | change,
@ -73,14 +65,23 @@ mod chmod_rs {
}
}
pub fn parse_symbolic(mut fperm: libc::mode_t, mut mode: &str, considering_dir: bool) -> Result<libc::mode_t, String> {
pub fn parse_symbolic(mut fperm: u32, mut mode: &str, considering_dir: bool) -> Result<u32, String> {
#[cfg(unix)]
use libc::umask;
#[cfg(target_os = "redox")]
unsafe fn umask(_mask: u32) -> u32 {
// XXX Redox does not currently have umask
0
}
let (mask, pos) = parse_levels(mode);
if pos == mode.len() {
return Err(format!("invalid mode ({})", mode));
}
let respect_umask = pos == 0;
let last_umask = unsafe {
libc::umask(0)
umask(0)
};
mode = &mode[pos..];
while mode.len() > 0 {
@ -88,7 +89,7 @@ mod chmod_rs {
mode = &mode[pos..];
let (mut srwx, pos) = parse_change(mode, fperm, considering_dir);
if respect_umask {
srwx &= !last_umask;
srwx &= !(last_umask as u32);
}
mode = &mode[pos..];
match op {
@ -99,12 +100,12 @@ mod chmod_rs {
}
}
unsafe {
libc::umask(last_umask);
umask(last_umask);
}
Ok(fperm)
}
fn parse_levels(mode: &str) -> (libc::mode_t, usize) {
fn parse_levels(mode: &str) -> (u32, usize) {
let mut mask = 0;
let mut pos = 0;
for ch in mode.chars() {
@ -136,7 +137,7 @@ mod chmod_rs {
}
}
fn parse_change(mode: &str, fperm: libc::mode_t, considering_dir: bool) -> (libc::mode_t, usize) {
fn parse_change(mode: &str, fperm: u32, considering_dir: bool) -> (u32, usize) {
let mut srwx = fperm & 0o7000;
let mut pos = 0;
for ch in mode.chars() {

View file

@ -8,7 +8,7 @@ name = "uu_kill"
path = "kill.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_link"
path = "link.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_ln"
path = "ln.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_logname"
path = "logname.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,13 +8,13 @@ name = "uu_ls"
path = "ls.rs"
[dependencies]
getopts = "*"
pretty-bytes = "*"
term_grid = "*"
termsize = "*"
time = "*"
lazy_static = "*"
unicode-width = "*"
getopts = "0.2.14"
pretty-bytes = "0.2.1"
term_grid = "0.1.5"
termsize = "0.1.4"
time = "0.1.38"
lazy_static = "0.2.8"
unicode-width = "0.1.4"
[dependencies.uucore]
path = "../uucore"

View file

@ -31,10 +31,11 @@ use std::fs;
use std::fs::{DirEntry, FileType, Metadata};
use std::path::{Path, PathBuf};
use std::io::Write;
use std::cmp::Reverse;
#[cfg(unix)]
use std::collections::HashMap;
#[cfg(unix)]
#[cfg(any(unix, target_os = "redox"))]
use std::os::unix::fs::MetadataExt;
#[cfg(unix)]
use std::os::unix::fs::FileTypeExt;
@ -183,17 +184,22 @@ fn list(options: getopts::Matches) {
}
}
#[cfg(unix)]
#[cfg(any(unix, target_os = "redox"))]
fn sort_entries(entries: &mut Vec<PathBuf>, options: &getopts::Matches) {
let mut reverse = options.opt_present("r");
if options.opt_present("t") {
if options.opt_present("c") {
entries.sort_by_key(|k| get_metadata(k, options).map(|md| md.ctime()).unwrap_or(0));
entries.sort_by_key(|k| {
Reverse(get_metadata(k, options)
.map(|md| md.ctime())
.unwrap_or(0))
});
} else {
entries.sort_by_key(|k| {
get_metadata(k, options)
// Newest first
Reverse(get_metadata(k, options)
.and_then(|md| md.modified())
.unwrap_or(std::time::UNIX_EPOCH)
.unwrap_or(std::time::UNIX_EPOCH))
});
}
} else if options.opt_present("S") {
@ -213,9 +219,10 @@ fn sort_entries(entries: &mut Vec<PathBuf>, options: &getopts::Matches) {
let mut reverse = options.opt_present("r");
if options.opt_present("t") {
entries.sort_by_key(|k| {
get_metadata(k, options)
// Newest first
Reverse(get_metadata(k, options)
.and_then(|md| md.modified())
.unwrap_or(std::time::UNIX_EPOCH)
.unwrap_or(std::time::UNIX_EPOCH))
});
} else if options.opt_present("S") {
entries.sort_by_key(|k| get_metadata(k, options).map(|md| md.file_size()).unwrap_or(0));

View file

@ -8,8 +8,8 @@ name = "uu_mkdir"
path = "mkdir.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_mkfifo"
path = "mkfifo.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_mknod"
path = "mknod.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
libc = "^0.2.4"
uucore = { path="../uucore" }

View file

@ -9,9 +9,9 @@ path = "mktemp.rs"
[dependencies]
uucore = { path="../uucore" }
getopts = "*"
getopts = "0.2.14"
rand = "0.3"
tempfile = "*"
tempfile = "2.1.5"
[[bin]]
name = "mktemp"

View file

@ -11,7 +11,7 @@ use std::path::Path;
// enough that an attacker will run out of luck before we run out of patience.
const NUM_RETRIES: u32 = 1 << 31;
#[cfg(unix)]
#[cfg(any(unix, target_os = "redox"))]
fn create_dir<P: AsRef<Path>>(path: P) -> IOResult<()> {
use std::fs::DirBuilder;
use std::os::unix::fs::DirBuilderExt;

View file

@ -8,11 +8,11 @@ name = "uu_more"
path = "more.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies]
nix = "*"
nix = "0.8.1"
[[bin]]
name = "more"

View file

@ -8,7 +8,7 @@ name = "uu_mv"
path = "mv.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_nice"
path = "nice.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,12 +8,12 @@ name = "uu_nl"
path = "nl.rs"
[dependencies]
getopts = "*"
libc = "*"
aho-corasick = "*"
memchr = "*"
regex = "*"
regex-syntax = "*"
getopts = "0.2.14"
libc = "0.2.26"
aho-corasick = "0.6.3"
memchr = "1.0.1"
regex = "0.2.2"
regex-syntax = "0.4.1"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_nohup"
path = "nohup.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_nproc"
path = "nproc.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
num_cpus = "1.5"
uucore = { path="../uucore" }

View file

@ -8,10 +8,10 @@ name = "uu_od"
path = "od.rs"
[dependencies]
getopts = "*"
libc = "*"
byteorder = "*"
half = "*"
getopts = "0.2.14"
libc = "0.2.26"
byteorder = "1.1.0"
half = "1.0.0"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_paste"
path = "paste.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_pathchk"
path = "pathchk.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_printenv"
path = "printenv.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_printf"
path = "printf.rs"
[dependencies]
"itertools" = "*"
"itertools" = "0.6.0"
uucore = { path="../uucore" }
[[bin]]

View file

@ -3,13 +3,12 @@
#![allow(dead_code)]
extern crate itertools;
extern crate uucore;
mod cli;
mod memo;
mod tokenize;
#[macro_use]
extern crate uucore;
static NAME: &'static str = "printf";
static VERSION: &'static str = "0.0.1";

View file

@ -8,12 +8,12 @@ name = "uu_ptx"
path = "ptx.rs"
[dependencies]
getopts = "0.2"
libc = "0.2"
aho-corasick = "0.6"
memchr = "1.0"
regex-syntax = "0.4"
regex = "0.2"
getopts = "0.2.14"
libc = "0.2.26"
aho-corasick = "0.6.3"
memchr = "1.0.1"
regex-syntax = "0.4.1"
regex = "0.2.2"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_pwd"
path = "pwd.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_readlink"
path = "readlink.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_realpath"
path = "realpath.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_relpath"
path = "relpath.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,9 @@ name = "uu_rm"
path = "rm.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
walkdir = "1.0.7"
remove_dir_all = "0.2"
uucore = { path="../uucore" }
[[bin]]

View file

@ -10,6 +10,8 @@
*/
extern crate getopts;
extern crate remove_dir_all;
extern crate walkdir;
#[macro_use]
extern crate uucore;
@ -18,7 +20,9 @@ use std::collections::VecDeque;
use std::fs;
use std::io::{stdin, stderr, BufRead, Write};
use std::ops::BitOr;
use std::path::{Path, PathBuf};
use std::path::Path;
use remove_dir_all::remove_dir_all;
use walkdir::{DirEntry, WalkDir};
#[derive(Eq, PartialEq, Clone, Copy)]
enum InteractiveMode {
@ -27,6 +31,17 @@ enum InteractiveMode {
InteractiveAlways
}
struct Options {
force: bool,
interactive: InteractiveMode,
#[allow(dead_code)]
one_fs: bool,
preserve_root: bool,
recursive: bool,
dir: bool,
verbose: bool
}
static NAME: &'static str = "rm";
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
@ -77,32 +92,36 @@ pub fn uumain(args: Vec<String>) -> i32 {
show_error!("for help, try '{0} --help'", NAME);
return 1;
} else {
let force = matches.opt_present("force");
let interactive =
if matches.opt_present("i") {
InteractiveMode::InteractiveAlways
} else if matches.opt_present("I") {
InteractiveMode::InteractiveOnce
} else if matches.opt_present("interactive") {
match &matches.opt_str("interactive").unwrap()[..] {
"none" => InteractiveMode::InteractiveNone,
"once" => InteractiveMode::InteractiveOnce,
"always" => InteractiveMode::InteractiveAlways,
val => {
crash!(1, "Invalid argument to interactive ({})", val)
let options = Options {
force: matches.opt_present("force"),
interactive: {
if matches.opt_present("i") {
InteractiveMode::InteractiveAlways
} else if matches.opt_present("I") {
InteractiveMode::InteractiveOnce
} else if matches.opt_present("interactive") {
match &matches.opt_str("interactive").unwrap()[..] {
"none" => InteractiveMode::InteractiveNone,
"once" => InteractiveMode::InteractiveOnce,
"always" => InteractiveMode::InteractiveAlways,
val => {
crash!(1, "Invalid argument to interactive ({})", val)
}
}
} else {
InteractiveMode::InteractiveNone
}
} else {
InteractiveMode::InteractiveNone
};
let one_fs = matches.opt_present("one-file-system");
let preserve_root = !matches.opt_present("no-preserve-root");
let recursive = matches.opt_present("recursive");
let dir = matches.opt_present("dir");
let verbose = matches.opt_present("verbose");
if interactive == InteractiveMode::InteractiveOnce && (recursive || matches.free.len() > 3) {
},
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")
};
if options.interactive == InteractiveMode::InteractiveOnce
&& (options.recursive || matches.free.len() > 3) {
let msg =
if recursive {
if options.recursive {
"Remove all arguments recursively? "
} else {
"Remove all arguments? "
@ -112,7 +131,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
}
if remove(matches.free, force, interactive, one_fs, preserve_root, recursive, dir, verbose) {
if remove(matches.free, options) {
return 1;
}
}
@ -120,118 +139,100 @@ pub fn uumain(args: Vec<String>) -> i32 {
0
}
// TODO: implement one-file-system
#[allow(unused_variables)]
fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> bool {
// TODO: implement one-file-system (this may get partially implemented in walkdir)
fn remove(files: Vec<String>, options: Options) -> bool {
let mut had_err = false;
for filename in &files {
let filename = &filename[..];
let file = Path::new(filename);
match file.symlink_metadata() {
Ok(metadata) => if metadata.is_dir() {
if recursive && (filename != "/" || !preserve_root) {
if interactive != InteractiveMode::InteractiveAlways {
if let Err(e) = fs::remove_dir_all(file) {
had_err = true;
show_error!("could not remove '{}': {}", filename, e);
};
} else {
let mut dirs: VecDeque<PathBuf> = VecDeque::new();
let mut files: Vec<PathBuf> = Vec::new();
let mut rmdirstack: Vec<PathBuf> = Vec::new();
dirs.push_back(file.to_path_buf());
while !dirs.is_empty() {
let dir = dirs.pop_front().unwrap();
if !prompt(&(format!("rm: descend into directory '{}'? ", dir.display()))[..]) {
continue;
}
// iterate over items in this directory, adding to either file or
// directory queue
match fs::read_dir(dir.as_path()) {
Ok(rdir) => {
for ent in rdir {
match ent {
Ok(ref f) => match f.file_type() {
Ok(t) => {
if t.is_dir() {
dirs.push_back(f.path());
} else {
files.push(f.path());
}
},
Err(e) => {
had_err = true;
show_error!("reading '{}': {}", f.path().display(), e);
},
},
Err(ref e) => {
had_err = true;
show_error!("recursing into '{}': {}", filename, e);
},
};
}
},
Err(e) => {
had_err = true;
show_error!("could not recurse into '{}': {}", dir.display(), e);
continue;
},
};
for f in &files {
had_err = remove_file(f.as_path(), interactive, verbose).bitor(had_err);
}
files.clear();
rmdirstack.push(dir);
}
for d in rmdirstack.iter().rev() {
had_err = remove_dir(d.as_path(), interactive, verbose).bitor(had_err);
}
}
} else if dir && (filename != "/" || !preserve_root) {
had_err = remove_dir(&file, interactive, verbose).bitor(had_err);
had_err = match file.symlink_metadata() {
Ok(metadata) => {
if metadata.is_dir() {
handle_dir(file, &options)
} else {
if recursive {
show_error!("could not remove directory '{}'", filename);
had_err = true;
} else {
show_error!("could not remove directory '{}' (did you mean to pass '-r'?)", filename);
had_err = true;
}
remove_file(file, &options)
}
} else {
had_err = remove_file(&file, interactive, verbose).bitor(had_err);
},
Err(e) => {
}
Err(_e) => {
// TODO: actually print out the specific error
// TODO: When the error is not about missing files
// (e.g., permission), even rm -f should fail with
// outputting the error, but there's no easy eay.
if !force {
had_err = true;
if !options.force {
show_error!("no such file or directory '{}'", filename);
true
} else {
false
}
}
}.bitor(had_err);
}
had_err
}
fn handle_dir(path: &Path, options: &Options) -> bool {
let mut had_err = false;
let is_root = path.has_root() && path.parent().is_none();
if options.recursive && (!is_root || !options.preserve_root) {
if options.interactive != InteractiveMode::InteractiveAlways {
// we need the extra crate because apparently fs::remove_dir_all() does not function
// correctly on Windows
if let Err(e) = remove_dir_all(path) {
had_err = true;
show_error!("could not remove '{}': {}", path.display(), e);
}
} else {
let mut dirs: VecDeque<DirEntry> = VecDeque::new();
for entry in WalkDir::new(path) {
match entry {
Ok(entry) => {
let file_type = entry.file_type();
if file_type.is_dir() {
dirs.push_back(entry);
} else {
had_err = remove_file(entry.path(), options).bitor(had_err);
}
}
Err(e) => {
had_err = true;
show_error!("recursing in '{}': {}", path.display(), e);
}
}
}
for dir in dirs.iter().rev() {
had_err = remove_dir(dir.path(), options).bitor(had_err);
}
}
} else if options.dir && (!is_root || !options.preserve_root) {
had_err = remove_dir(path, options).bitor(had_err);
} else {
if options.recursive {
show_error!("could not remove directory '{}'", path.display());
had_err = true;
} else {
show_error!("could not remove directory '{}' (did you mean to pass '-r'?)",
path.display());
had_err = true;
}
}
had_err
}
fn remove_dir(path: &Path, interactive: InteractiveMode, verbose: bool) -> bool {
fn remove_dir(path: &Path, options: &Options) -> bool {
let response =
if interactive == InteractiveMode::InteractiveAlways {
if options.interactive == InteractiveMode::InteractiveAlways {
prompt_file(path, true)
} else {
true
};
if response {
match fs::remove_dir(path) {
Ok(_) => if verbose { println!("removed '{}'", path.display()); },
Ok(_) => if options.verbose { println!("removed '{}'", path.display()); },
Err(e) => {
show_error!("removing '{}': {}", path.display(), e);
return true;
@ -242,16 +243,16 @@ fn remove_dir(path: &Path, interactive: InteractiveMode, verbose: bool) -> bool
false
}
fn remove_file(path: &Path, interactive: InteractiveMode, verbose: bool) -> bool {
fn remove_file(path: &Path, options: &Options) -> bool {
let response =
if interactive == InteractiveMode::InteractiveAlways {
if options.interactive == InteractiveMode::InteractiveAlways {
prompt_file(path, false)
} else {
true
};
if response {
match fs::remove_file(path) {
Ok(_) => if verbose { println!("removed '{}'", path.display()); },
Ok(_) => if options.verbose { println!("removed '{}'", path.display()); },
Err(e) => {
show_error!("removing '{}': {}", path.display(), e);
return true;
@ -264,22 +265,24 @@ fn remove_file(path: &Path, interactive: InteractiveMode, verbose: bool) -> bool
fn prompt_file(path: &Path, is_dir: bool) -> bool {
if is_dir {
prompt(&(format!("rm: remove directory '{}'? ", path.display()))[..])
prompt(&(format!("rm: remove directory '{}'? ", path.display())))
} else {
prompt(&(format!("rm: remove file '{}'? ", path.display()))[..])
prompt(&(format!("rm: remove file '{}'? ", path.display())))
}
}
fn prompt(msg: &str) -> bool {
stderr().write_all(msg.as_bytes()).unwrap_or(());
stderr().flush().unwrap_or(());
let _ = stderr().write_all(msg.as_bytes());
let _ = stderr().flush();
let mut buf = Vec::new();
let stdin = stdin();
let mut stdin = stdin.lock();
match stdin.read_until('\n' as u8, &mut buf) {
Ok(x) if x > 0 => {
match buf[0] {
0x59 | 0x79 => true,
b'y' | b'Y' => true,
_ => false,
}
}

View file

@ -8,7 +8,7 @@ name = "uu_rmdir"
path = "rmdir.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_seq"
path = "seq.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -9,10 +9,10 @@ path = "shred.rs"
[dependencies]
rand = "0.3"
filetime = "*"
getopts = "*"
libc = "*"
time = "*"
filetime = "0.1.10"
getopts = "0.2.14"
libc = "0.2.26"
time = "0.1.38"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_shuf"
path = "shuf.rs"
[dependencies]
getopts = "*"
rand = "*"
getopts = "0.2.14"
rand = "0.3.15"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_sleep"
path = "sleep.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,9 +8,9 @@ name = "uu_sort"
path = "sort.rs"
[dependencies]
getopts = "*"
semver = "*"
itertools = "*"
getopts = "0.2.14"
semver = "0.7.0"
itertools = "0.6.0"
uucore = { path="../uucore" }
[[bin]]

View file

@ -16,7 +16,6 @@ extern crate semver;
#[macro_use]
extern crate uucore;
#[macro_use]
extern crate itertools;
use std::cmp::Ordering;

View file

@ -8,7 +8,7 @@ name = "uu_split"
path = "split.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_stat"
path = "stat.rs"
[dependencies]
getopts = "*"
time = "*"
getopts = "0.2.14"
time = "0.1.38"
[dependencies.uucore]
path = "../uucore"

View file

@ -8,7 +8,7 @@ name = "uu_stdbuf"
path = "stdbuf.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_sum"
path = "sum.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,10 +8,10 @@ name = "uu_sync"
path = "sync.rs"
[dependencies]
getopts = "*"
libc = "*"
winapi = "*"
kernel32-sys = "*"
getopts = "0.2.14"
libc = "0.2.26"
winapi = "0.2.8"
kernel32-sys = "0.2.2"
uucore = { path="../uucore" }
[[bin]]

View file

@ -14,9 +14,13 @@
extern crate getopts;
extern crate libc;
#[cfg(windows)]
#[macro_use]
extern crate uucore;
#[cfg(not(windows))]
extern crate uucore;
static NAME: &'static str = "sync";
static VERSION: &'static str = env!("CARGO_PKG_VERSION");

View file

@ -8,7 +8,7 @@ name = "uu_tac"
path = "tac.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,10 +8,10 @@ name = "uu_tail"
path = "tail.rs"
[dependencies]
getopts = "*"
kernel32-sys = "*"
libc = "*"
winapi = "*"
getopts = "0.2.14"
kernel32-sys = "0.2.2"
libc = "0.2.26"
winapi = "0.2.8"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_tee"
path = "tee.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_test"
path = "test.rs"
[dependencies]
libc = "*"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,9 +8,9 @@ name = "uu_timeout"
path = "timeout.rs"
[dependencies]
getopts = "*"
libc = "*"
time = "*"
getopts = "0.2.14"
libc = "0.2.26"
time = "0.1.38"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,9 +8,9 @@ name = "uu_touch"
path = "touch.rs"
[dependencies]
filetime = "*"
getopts = "*"
time = "*"
filetime = "0.1.10"
getopts = "0.2.14"
time = "0.1.38"
[dependencies.uucore]
path = "../uucore"

View file

@ -8,9 +8,9 @@ name = "uu_tr"
path = "tr.rs"
[dependencies]
getopts = "*"
bit-set = "*"
fnv = "*"
getopts = "0.2.14"
bit-set = "0.4.0"
fnv = "1.0.5"
[dependencies.uucore]
path = "../uucore"

View file

@ -32,66 +32,131 @@ static NAME: &'static str = "tr";
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
const BUFFER_LEN: usize = 1024;
fn delete(set: ExpandSet, complement: bool) {
let mut bset = BitSet::new();
let stdin = stdin();
let mut locked_stdin = stdin.lock();
let mut buffered_stdout = BufWriter::new(stdout());
let mut buf = String::with_capacity(BUFFER_LEN + 4);
let mut char_output_buffer: [u8; 4] = [0;4];
trait SymbolTranslator {
fn translate(&self, c: &char, prev_c: &char) -> Option<char>;
}
for c in set {
bset.insert(c as usize);
}
struct DeleteOperation {
bset: BitSet,
complement: bool,
}
let is_allowed = |c : char| {
if complement {
bset.contains(c as usize)
} else {
!bset.contains(c as usize)
impl DeleteOperation {
fn new(set: ExpandSet, complement: bool) -> DeleteOperation {
DeleteOperation {
bset: set.map(|c| c as usize).collect(),
complement: complement
}
};
while let Ok(length) = locked_stdin.read_line(&mut buf) {
if length == 0 { break }
{ // isolation to make borrow checker happy
let filtered = buf.chars().filter(|c| is_allowed(*c));
for c in filtered {
let char_as_bytes = c.encode_utf8(&mut char_output_buffer);
buffered_stdout.write_all(char_as_bytes.as_bytes()).unwrap();
}
}
buf.clear();
}
}
fn tr<'a>(set1: ExpandSet<'a>, mut set2: ExpandSet<'a>) {
let mut map = FnvHashMap::default();
let stdin = stdin();
let mut locked_stdin = stdin.lock();
let mut buffered_stdout = BufWriter::new(stdout());
let mut buf = String::with_capacity(BUFFER_LEN + 4);
let mut char_output_buffer: [u8; 4] = [0;4];
let mut s2_prev = '_';
for i in set1 {
s2_prev = set2.next().unwrap_or(s2_prev);
map.insert(i as usize, s2_prev);
}
while let Ok(length) = locked_stdin.read_line(&mut buf) {
if length == 0 { break }
{ // isolation to make borrow checker happy
let output_stream = buf.chars().map(|c| *map.get(&(c as usize)).unwrap_or(&c));
for c in output_stream {
let char_as_bytes = c.encode_utf8(&mut char_output_buffer);
buffered_stdout.write_all(char_as_bytes.as_bytes()).unwrap();
}
impl SymbolTranslator for DeleteOperation {
fn translate(&self, c: &char, _prev_c: &char) -> Option<char> {
let uc = *c as usize;
if self.complement == self.bset.contains(uc) {
Some(*c)
} else {
None
}
}
}
struct SqueezeOperation {
squeeze_set: BitSet,
complement: bool,
}
impl SqueezeOperation {
fn new(squeeze_set: ExpandSet, complement: bool) -> SqueezeOperation {
SqueezeOperation {
squeeze_set: squeeze_set.map(|c| c as usize).collect(),
complement: complement
}
}
}
impl SymbolTranslator for SqueezeOperation {
fn translate(&self, c: &char, prev_c: &char) -> Option<char> {
if *prev_c == *c && self.complement != self.squeeze_set.contains(*c as usize) {
None
} else {
Some(*c)
}
}
}
struct DeleteAndSqueezeOperation {
delete_set: BitSet,
squeeze_set: BitSet,
complement: bool,
}
impl DeleteAndSqueezeOperation {
fn new(delete_set: ExpandSet, squeeze_set: ExpandSet, complement: bool) -> DeleteAndSqueezeOperation {
DeleteAndSqueezeOperation {
delete_set: delete_set.map(|c| c as usize).collect(),
squeeze_set: squeeze_set.map(|c| c as usize).collect(),
complement: complement
}
}
}
impl SymbolTranslator for DeleteAndSqueezeOperation {
fn translate(&self, c: &char, prev_c: &char) -> Option<char> {
if self.complement != self.delete_set.contains(*c as usize) || *prev_c == *c && self.squeeze_set.contains(*c as usize) {
None
} else {
Some(*c)
}
}
}
struct TranslateOperation {
translate_map: FnvHashMap<usize, char>,
}
impl TranslateOperation {
fn new(set1: ExpandSet, set2: &mut ExpandSet) -> TranslateOperation {
let mut map = FnvHashMap::default();
let mut s2_prev = '_';
for i in set1 {
s2_prev = set2.next().unwrap_or(s2_prev);
map.insert(i as usize, s2_prev);
}
TranslateOperation {
translate_map: map,
}
}
}
impl SymbolTranslator for TranslateOperation {
fn translate(&self, c: &char, _prev_c: &char) -> Option<char> {
Some(*self.translate_map.get(&(*c as usize)).unwrap_or(c))
}
}
fn translate_input<T: SymbolTranslator>(input: &mut BufRead, output: &mut Write, translator: T) {
let mut buf = String::with_capacity(BUFFER_LEN + 4);
let mut output_buf = String::with_capacity(BUFFER_LEN + 4);
while let Ok(length) = input.read_line(&mut buf) {
let mut prev_c = 0 as char;
if length == 0 { break }
{ // isolation to make borrow checker happy
let filtered = buf.chars().filter_map(|c| {
let res = translator.translate(&c, &prev_c);
if res.is_some() {
prev_c = c;
}
res
});
output_buf.extend(filtered);
output.write_all(output_buf.as_bytes()).unwrap();
}
buf.clear();
output_buf.clear();
}
}
@ -111,6 +176,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
opts.optflag("C", "", "same as -c");
opts.optflag("d", "delete", "delete characters in SET1");
opts.optflag("h", "help", "display this help and exit");
opts.optflag("s", "squeeze", "replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character");
opts.optflag("V", "version", "output version information and exit");
let matches = match opts.parse(&args[1..]) {
@ -138,20 +204,37 @@ pub fn uumain(args: Vec<String>) -> i32 {
let dflag = matches.opt_present("d");
let cflag = matches.opts_present(&["c".to_owned(), "C".to_owned()]);
let sflag = matches.opt_present("s");
let sets = matches.free;
if cflag && !dflag {
show_error!("-c is only supported with -d");
if cflag && !dflag && !sflag {
show_error!("-c is only supported with -d or -s");
return 1;
}
let stdin = stdin();
let mut locked_stdin = stdin.lock();
let stdout = stdout();
let locked_stdout = stdout.lock();
let mut buffered_stdout = BufWriter::new(locked_stdout);
let set1 = ExpandSet::new(sets[0].as_ref());
if dflag {
let set1 = ExpandSet::new(sets[0].as_ref());
delete(set1, cflag);
if sflag {
let set2 = ExpandSet::new(sets[1].as_ref());
let op = DeleteAndSqueezeOperation::new(set1, set2, cflag);
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
} else {
let op = DeleteOperation::new(set1, cflag);
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
}
} else if sflag {
let op = SqueezeOperation::new(set1, cflag);
translate_input(&mut locked_stdin, &mut buffered_stdout, op);
} else {
let set1 = ExpandSet::new(sets[0].as_ref());
let set2 = ExpandSet::new(sets[1].as_ref());
tr(set1, set2);
let mut set2 = ExpandSet::new(sets[1].as_ref());
let op = TranslateOperation::new(set1, &mut set2);
translate_input(&mut locked_stdin, &mut buffered_stdout, op)
}
0

View file

@ -8,7 +8,7 @@ name = "uu_truncate"
path = "truncate.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_tsort"
path = "tsort.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_tty"
path = "tty.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,8 +8,8 @@ name = "uu_unexpand"
path = "unexpand.rs"
[dependencies]
getopts = "*"
unicode-width = "*"
getopts = "0.2.14"
unicode-width = "0.1.4"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_uniq"
path = "uniq.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
[dependencies.uucore]
path="../uucore"

View file

@ -8,8 +8,8 @@ name = "uu_unlink"
path = "unlink.rs"
[dependencies]
getopts = "*"
libc = "*"
getopts = "0.2.14"
libc = "0.2.26"
uucore = { path="../uucore" }
[[bin]]

View file

@ -8,7 +8,7 @@ name = "uu_uptime"
path = "uptime.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
[dependencies.uucore]
path = "../uucore"

View file

@ -8,7 +8,7 @@ name = "uu_users"
path = "users.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
[dependencies.uucore]
default-features = false

View file

@ -16,9 +16,8 @@
#![allow(dead_code)]
extern crate getopts;
#[macro_use]
extern crate uucore;
use uucore::utmpx::*;
use getopts::Options;

View file

@ -4,8 +4,8 @@ version = "0.0.1"
authors = []
[dependencies]
getopts = "*"
time = { version = "*", optional = true }
getopts = "0.2.14"
time = { version = "0.1.38", optional = true }
data-encoding = { version = "^1.1", optional = true }
[dependencies.libc]

View file

@ -8,7 +8,7 @@ name = "uu_wc"
path = "wc.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

View file

@ -13,7 +13,7 @@ default-features = false
features = ["utmpx"]
[dependencies.clippy]
version = "*"
version = "0.0.143"
optional = true
[[bin]]

View file

@ -8,9 +8,9 @@ name = "uu_whoami"
path = "whoami.rs"
[dependencies]
getopts = "*"
winapi = "*"
advapi32-sys = "*"
getopts = "0.2.14"
winapi = "0.2.8"
advapi32-sys = "0.2.0"
[dependencies.uucore]
path = "../uucore"

View file

@ -8,7 +8,7 @@ name = "uu_yes"
path = "yes.rs"
[dependencies]
getopts = "*"
getopts = "0.2.14"
uucore = { path="../uucore" }
[[bin]]

1
tests/fixtures/cp/existing_file.txt vendored Normal file
View file

@ -0,0 +1 @@
Cogito ergo sum.

1
tests/fixtures/cp/how_are_you.txt vendored Normal file
View file

@ -0,0 +1 @@
How are you?

View file

@ -1,10 +1,17 @@
use common::util::*;
use std::fs::set_permissions;
static TEST_HELLO_WORLD_SOURCE: &'static str = "hello_world.txt";
static TEST_HELLO_WORLD_DEST: &'static str = "copy_of_hello_world.txt";
static TEST_COPY_TO_FOLDER: &'static str = "hello_dir/";
static TEST_COPY_TO_FOLDER_FILE: &'static str = "hello_dir/hello_world.txt";
static TEST_COPY_FROM_FOLDER_FILE: &'static str = "hello_dir_with_file/hello_world.txt";
static TEST_EXISTING_FILE: &str = "existing_file.txt";
static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt";
static TEST_HELLO_WORLD_DEST: &str = "copy_of_hello_world.txt";
static TEST_HOW_ARE_YOU_SOURCE: &str = "how_are_you.txt";
static TEST_HOW_ARE_YOU_DEST: &str = "hello_dir/how_are_you.txt";
static TEST_COPY_TO_FOLDER: &str = "hello_dir/";
static TEST_COPY_TO_FOLDER_FILE: &str = "hello_dir/hello_world.txt";
static TEST_COPY_FROM_FOLDER: &str = "hello_dir_with_file/";
static TEST_COPY_FROM_FOLDER_FILE: &str = "hello_dir_with_file/hello_world.txt";
static TEST_COPY_TO_FOLDER_NEW: &str = "hello_dir_new/";
static TEST_COPY_TO_FOLDER_NEW_FILE: &str = "hello_dir_new/hello_world.txt";
#[test]
fn test_cp_cp() {
@ -22,6 +29,73 @@ fn test_cp_cp() {
assert_eq!(at.read(TEST_HELLO_WORLD_DEST), "Hello, World!\n");
}
#[test]
fn test_cp_duplicate_files() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_COPY_TO_FOLDER)
.run();
assert!(result.success);
assert!(result.stderr.contains("specified more than once"));
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
}
#[test]
fn test_cp_multiple_files_target_is_file() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_EXISTING_FILE)
.run();
assert!(!result.success);
assert!(result.stderr.contains("not a directory"));
}
#[test]
fn test_cp_directory_not_recursive() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_COPY_TO_FOLDER)
.arg(TEST_HELLO_WORLD_DEST)
.run();
assert!(!result.success);
assert!(result.stderr.contains("omitting directory"));
}
#[test]
fn test_cp_multiple_files() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg(TEST_COPY_TO_FOLDER)
.run();
assert!(result.success);
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
}
#[test]
fn test_cp_recurse() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd
.arg("-r")
.arg(TEST_COPY_FROM_FOLDER)
.arg(TEST_COPY_TO_FOLDER_NEW)
.run();
assert!(result.success);
// Check the content of the destination file that was copied.
assert_eq!(at.read(TEST_COPY_TO_FOLDER_NEW_FILE), "Hello, World!\n");
}
#[test]
fn test_cp_with_dirs_t() {
let (at, mut ucmd) = at_and_ucmd!();
@ -56,3 +130,156 @@ fn test_cp_with_dirs() {
assert!(result_from_dir.success);
assert_eq!(at.read(TEST_HELLO_WORLD_DEST), "Hello, World!\n");
}
#[test]
fn test_cp_arg_target_directory() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("-t")
.arg(TEST_COPY_TO_FOLDER)
.run();
assert!(result.success);
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
}
#[test]
fn test_cp_arg_no_target_directory() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("-v")
.arg("-T")
.arg(TEST_COPY_TO_FOLDER)
.run();
assert!(!result.success);
assert!(result.stderr.contains("cannot overwrite directory"));
}
#[test]
fn test_cp_arg_interactive() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("-i")
.pipe_in("N\n")
.run();
assert!(result.success);
assert!(result.stderr.contains("Not overwriting"));
}
#[test]
#[cfg(target_os="unix")]
fn test_cp_arg_link() {
use std::os::linux::fs::MetadataExt;
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--link")
.arg(TEST_HELLO_WORLD_DEST)
.run();
assert!(result.success);
assert_eq!(at.metadata(TEST_HELLO_WORLD_SOURCE).st_nlink(), 2);
}
#[test]
fn test_cp_arg_symlink() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--symbolic-link")
.arg(TEST_HELLO_WORLD_DEST)
.run();
assert!(result.success);
assert!(at.is_symlink(TEST_HELLO_WORLD_DEST));
}
#[test]
fn test_cp_arg_no_clobber() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--no-clobber")
.arg(TEST_HOW_ARE_YOU_SOURCE)
.run();
assert!(result.success);
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
assert!(result.stderr.contains("Not overwriting"));
}
#[test]
#[cfg(not(windows))]
fn test_cp_arg_force() {
let (at, mut ucmd) = at_and_ucmd!();
// create dest without write permissions
let mut permissions = at.make_file(TEST_HELLO_WORLD_DEST).metadata().unwrap().permissions();
permissions.set_readonly(true);
set_permissions(at.plus(TEST_HELLO_WORLD_DEST), permissions).unwrap();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--force")
.arg(TEST_HELLO_WORLD_DEST)
.run();
println!("{:?}", result.stderr);
println!("{:?}", result.stdout);
assert!(result.success);
assert_eq!(at.read(TEST_HELLO_WORLD_DEST), "Hello, World!\n");
}
/// TODO: write a better test that differentiates --remove-destination
/// from --force. Also this test currently doesn't work on
/// Windows. This test originally checked file timestamps, which
/// proved to be unreliable per target / CI platform
#[test]
#[cfg(not(windows))]
fn test_cp_arg_remove_destination() {
let (at, mut ucmd) = at_and_ucmd!();
// create dest without write permissions
let mut permissions = at.make_file(TEST_HELLO_WORLD_DEST).metadata().unwrap().permissions();
permissions.set_readonly(true);
set_permissions(at.plus(TEST_HELLO_WORLD_DEST), permissions).unwrap();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--remove-destination")
.arg(TEST_HELLO_WORLD_DEST)
.run();
assert!(result.success);
assert_eq!(at.read(TEST_HELLO_WORLD_DEST), "Hello, World!\n");
}
#[test]
fn test_cp_arg_backup() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--backup")
.arg(TEST_HOW_ARE_YOU_SOURCE)
.run();
assert!(result.success);
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
assert_eq!(at.read(&*format!("{}~", TEST_HOW_ARE_YOU_SOURCE)), "How are you?\n");
}
#[test]
fn test_cp_arg_suffix() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("--suffix")
.arg(".bak")
.arg(TEST_HOW_ARE_YOU_SOURCE)
.run();
assert!(result.success);
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
assert_eq!(at.read(&*format!("{}.bak", TEST_HOW_ARE_YOU_SOURCE)), "How are you?\n");
}

View file

@ -32,3 +32,28 @@ fn test_delete_complement() {
new_ucmd!()
.args(&["-d", "-c", "a-z"]).pipe_in("aBcD").run().stdout_is("ac");
}
#[test]
fn test_squeeze() {
new_ucmd!()
.args(&["-s", "a-z"]).pipe_in("aaBBcDcc").run().stdout_is("aBBcDc");
}
#[test]
fn test_squeeze_complement() {
new_ucmd!()
.args(&["-sc", "a-z"]).pipe_in("aaBBcDcc").run().stdout_is("aaBcDcc");
}
#[test]
fn test_delete_and_squeeze() {
new_ucmd!()
.args(&["-ds", "a-z", "A-Z"]).pipe_in("abBcB").run().stdout_is("B");
}
#[test]
fn test_delete_and_squeeze_complement() {
new_ucmd!()
.args(&["-dsc", "a-z", "A-Z"]).pipe_in("abBcB").run().stdout_is("abc");
}