Merge branch 'main' into clap-3

This commit is contained in:
Terts Diepraam 2022-01-17 13:25:02 +01:00
commit 8872485922
135 changed files with 1758 additions and 840 deletions

View file

@ -13,7 +13,7 @@ env:
PROJECT_NAME: coreutils
PROJECT_DESC: "Core universal (cross-platform) utilities"
PROJECT_AUTH: "uutils"
RUST_MIN_SRV: "1.47.0" ## MSRV v1.47.0
RUST_MIN_SRV: "1.54.0" ## MSRV v1.54.0
# * style job configuration
STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis

499
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
[package]
name = "coreutils"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust"
@ -248,110 +248,110 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] }
clap_complete = "3.0"
lazy_static = { version="1.3" }
textwrap = { version="0.14", features=["terminal_size"] }
uucore = { version=">=0.0.10", package="uucore", path="src/uucore" }
uucore = { version=">=0.0.11", package="uucore", path="src/uucore" }
selinux = { version="0.2.3", optional = true }
# * uutils
uu_test = { optional=true, version="0.0.8", package="uu_test", path="src/uu/test" }
uu_test = { optional=true, version="0.0.9", package="uu_test", path="src/uu/test" }
#
arch = { optional=true, version="0.0.8", package="uu_arch", path="src/uu/arch" }
base32 = { optional=true, version="0.0.8", package="uu_base32", path="src/uu/base32" }
base64 = { optional=true, version="0.0.8", package="uu_base64", path="src/uu/base64" }
basename = { optional=true, version="0.0.8", package="uu_basename", path="src/uu/basename" }
basenc = { optional=true, version="0.0.8", package="uu_basenc", path="src/uu/basenc" }
cat = { optional=true, version="0.0.8", package="uu_cat", path="src/uu/cat" }
chcon = { optional=true, version="0.0.8", package="uu_chcon", path="src/uu/chcon" }
chgrp = { optional=true, version="0.0.8", package="uu_chgrp", path="src/uu/chgrp" }
chmod = { optional=true, version="0.0.8", package="uu_chmod", path="src/uu/chmod" }
chown = { optional=true, version="0.0.8", package="uu_chown", path="src/uu/chown" }
chroot = { optional=true, version="0.0.8", package="uu_chroot", path="src/uu/chroot" }
cksum = { optional=true, version="0.0.8", package="uu_cksum", path="src/uu/cksum" }
comm = { optional=true, version="0.0.8", package="uu_comm", path="src/uu/comm" }
cp = { optional=true, version="0.0.8", package="uu_cp", path="src/uu/cp" }
csplit = { optional=true, version="0.0.8", package="uu_csplit", path="src/uu/csplit" }
cut = { optional=true, version="0.0.8", package="uu_cut", path="src/uu/cut" }
date = { optional=true, version="0.0.8", package="uu_date", path="src/uu/date" }
dd = { optional=true, version="0.0.8", package="uu_dd", path="src/uu/dd" }
df = { optional=true, version="0.0.8", package="uu_df", path="src/uu/df" }
dircolors= { optional=true, version="0.0.8", package="uu_dircolors", path="src/uu/dircolors" }
dirname = { optional=true, version="0.0.8", package="uu_dirname", path="src/uu/dirname" }
du = { optional=true, version="0.0.8", package="uu_du", path="src/uu/du" }
echo = { optional=true, version="0.0.8", package="uu_echo", path="src/uu/echo" }
env = { optional=true, version="0.0.8", package="uu_env", path="src/uu/env" }
expand = { optional=true, version="0.0.8", package="uu_expand", path="src/uu/expand" }
expr = { optional=true, version="0.0.8", package="uu_expr", path="src/uu/expr" }
factor = { optional=true, version="0.0.8", package="uu_factor", path="src/uu/factor" }
false = { optional=true, version="0.0.8", package="uu_false", path="src/uu/false" }
fmt = { optional=true, version="0.0.8", package="uu_fmt", path="src/uu/fmt" }
fold = { optional=true, version="0.0.8", package="uu_fold", path="src/uu/fold" }
groups = { optional=true, version="0.0.8", package="uu_groups", path="src/uu/groups" }
hashsum = { optional=true, version="0.0.8", package="uu_hashsum", path="src/uu/hashsum" }
head = { optional=true, version="0.0.8", package="uu_head", path="src/uu/head" }
hostid = { optional=true, version="0.0.8", package="uu_hostid", path="src/uu/hostid" }
hostname = { optional=true, version="0.0.8", package="uu_hostname", path="src/uu/hostname" }
id = { optional=true, version="0.0.8", package="uu_id", path="src/uu/id" }
install = { optional=true, version="0.0.8", package="uu_install", path="src/uu/install" }
join = { optional=true, version="0.0.8", package="uu_join", path="src/uu/join" }
kill = { optional=true, version="0.0.8", package="uu_kill", path="src/uu/kill" }
link = { optional=true, version="0.0.8", package="uu_link", path="src/uu/link" }
ln = { optional=true, version="0.0.8", package="uu_ln", path="src/uu/ln" }
ls = { optional=true, version="0.0.8", package="uu_ls", path="src/uu/ls" }
logname = { optional=true, version="0.0.8", package="uu_logname", path="src/uu/logname" }
mkdir = { optional=true, version="0.0.8", package="uu_mkdir", path="src/uu/mkdir" }
mkfifo = { optional=true, version="0.0.8", package="uu_mkfifo", path="src/uu/mkfifo" }
mknod = { optional=true, version="0.0.8", package="uu_mknod", path="src/uu/mknod" }
mktemp = { optional=true, version="0.0.8", package="uu_mktemp", path="src/uu/mktemp" }
more = { optional=true, version="0.0.8", package="uu_more", path="src/uu/more" }
mv = { optional=true, version="0.0.8", package="uu_mv", path="src/uu/mv" }
nice = { optional=true, version="0.0.8", package="uu_nice", path="src/uu/nice" }
nl = { optional=true, version="0.0.8", package="uu_nl", path="src/uu/nl" }
nohup = { optional=true, version="0.0.8", package="uu_nohup", path="src/uu/nohup" }
nproc = { optional=true, version="0.0.8", package="uu_nproc", path="src/uu/nproc" }
numfmt = { optional=true, version="0.0.8", package="uu_numfmt", path="src/uu/numfmt" }
od = { optional=true, version="0.0.8", package="uu_od", path="src/uu/od" }
paste = { optional=true, version="0.0.8", package="uu_paste", path="src/uu/paste" }
pathchk = { optional=true, version="0.0.8", package="uu_pathchk", path="src/uu/pathchk" }
pinky = { optional=true, version="0.0.8", package="uu_pinky", path="src/uu/pinky" }
pr = { optional=true, version="0.0.8", package="uu_pr", path="src/uu/pr" }
printenv = { optional=true, version="0.0.8", package="uu_printenv", path="src/uu/printenv" }
printf = { optional=true, version="0.0.8", package="uu_printf", path="src/uu/printf" }
ptx = { optional=true, version="0.0.8", package="uu_ptx", path="src/uu/ptx" }
pwd = { optional=true, version="0.0.8", package="uu_pwd", path="src/uu/pwd" }
readlink = { optional=true, version="0.0.8", package="uu_readlink", path="src/uu/readlink" }
realpath = { optional=true, version="0.0.8", package="uu_realpath", path="src/uu/realpath" }
relpath = { optional=true, version="0.0.8", package="uu_relpath", path="src/uu/relpath" }
rm = { optional=true, version="0.0.8", package="uu_rm", path="src/uu/rm" }
rmdir = { optional=true, version="0.0.8", package="uu_rmdir", path="src/uu/rmdir" }
runcon = { optional=true, version="0.0.8", package="uu_runcon", path="src/uu/runcon" }
seq = { optional=true, version="0.0.8", package="uu_seq", path="src/uu/seq" }
shred = { optional=true, version="0.0.8", package="uu_shred", path="src/uu/shred" }
shuf = { optional=true, version="0.0.8", package="uu_shuf", path="src/uu/shuf" }
sleep = { optional=true, version="0.0.8", package="uu_sleep", path="src/uu/sleep" }
sort = { optional=true, version="0.0.8", package="uu_sort", path="src/uu/sort" }
split = { optional=true, version="0.0.8", package="uu_split", path="src/uu/split" }
stat = { optional=true, version="0.0.8", package="uu_stat", path="src/uu/stat" }
stdbuf = { optional=true, version="0.0.8", package="uu_stdbuf", path="src/uu/stdbuf" }
sum = { optional=true, version="0.0.8", package="uu_sum", path="src/uu/sum" }
sync = { optional=true, version="0.0.8", package="uu_sync", path="src/uu/sync" }
tac = { optional=true, version="0.0.8", package="uu_tac", path="src/uu/tac" }
tail = { optional=true, version="0.0.8", package="uu_tail", path="src/uu/tail" }
tee = { optional=true, version="0.0.8", package="uu_tee", path="src/uu/tee" }
timeout = { optional=true, version="0.0.8", package="uu_timeout", path="src/uu/timeout" }
touch = { optional=true, version="0.0.8", package="uu_touch", path="src/uu/touch" }
tr = { optional=true, version="0.0.8", package="uu_tr", path="src/uu/tr" }
true = { optional=true, version="0.0.8", package="uu_true", path="src/uu/true" }
truncate = { optional=true, version="0.0.8", package="uu_truncate", path="src/uu/truncate" }
tsort = { optional=true, version="0.0.8", package="uu_tsort", path="src/uu/tsort" }
tty = { optional=true, version="0.0.8", package="uu_tty", path="src/uu/tty" }
uname = { optional=true, version="0.0.8", package="uu_uname", path="src/uu/uname" }
unexpand = { optional=true, version="0.0.8", package="uu_unexpand", path="src/uu/unexpand" }
uniq = { optional=true, version="0.0.8", package="uu_uniq", path="src/uu/uniq" }
unlink = { optional=true, version="0.0.8", package="uu_unlink", path="src/uu/unlink" }
uptime = { optional=true, version="0.0.8", package="uu_uptime", path="src/uu/uptime" }
users = { optional=true, version="0.0.8", package="uu_users", path="src/uu/users" }
wc = { optional=true, version="0.0.8", package="uu_wc", path="src/uu/wc" }
who = { optional=true, version="0.0.8", package="uu_who", path="src/uu/who" }
whoami = { optional=true, version="0.0.8", package="uu_whoami", path="src/uu/whoami" }
yes = { optional=true, version="0.0.8", package="uu_yes", path="src/uu/yes" }
arch = { optional=true, version="0.0.9", package="uu_arch", path="src/uu/arch" }
base32 = { optional=true, version="0.0.9", package="uu_base32", path="src/uu/base32" }
base64 = { optional=true, version="0.0.9", package="uu_base64", path="src/uu/base64" }
basename = { optional=true, version="0.0.9", package="uu_basename", path="src/uu/basename" }
basenc = { optional=true, version="0.0.9", package="uu_basenc", path="src/uu/basenc" }
cat = { optional=true, version="0.0.9", package="uu_cat", path="src/uu/cat" }
chcon = { optional=true, version="0.0.9", package="uu_chcon", path="src/uu/chcon" }
chgrp = { optional=true, version="0.0.9", package="uu_chgrp", path="src/uu/chgrp" }
chmod = { optional=true, version="0.0.9", package="uu_chmod", path="src/uu/chmod" }
chown = { optional=true, version="0.0.9", package="uu_chown", path="src/uu/chown" }
chroot = { optional=true, version="0.0.9", package="uu_chroot", path="src/uu/chroot" }
cksum = { optional=true, version="0.0.9", package="uu_cksum", path="src/uu/cksum" }
comm = { optional=true, version="0.0.9", package="uu_comm", path="src/uu/comm" }
cp = { optional=true, version="0.0.9", package="uu_cp", path="src/uu/cp" }
csplit = { optional=true, version="0.0.9", package="uu_csplit", path="src/uu/csplit" }
cut = { optional=true, version="0.0.9", package="uu_cut", path="src/uu/cut" }
date = { optional=true, version="0.0.9", package="uu_date", path="src/uu/date" }
dd = { optional=true, version="0.0.9", package="uu_dd", path="src/uu/dd" }
df = { optional=true, version="0.0.9", package="uu_df", path="src/uu/df" }
dircolors= { optional=true, version="0.0.9", package="uu_dircolors", path="src/uu/dircolors" }
dirname = { optional=true, version="0.0.9", package="uu_dirname", path="src/uu/dirname" }
du = { optional=true, version="0.0.9", package="uu_du", path="src/uu/du" }
echo = { optional=true, version="0.0.9", package="uu_echo", path="src/uu/echo" }
env = { optional=true, version="0.0.9", package="uu_env", path="src/uu/env" }
expand = { optional=true, version="0.0.9", package="uu_expand", path="src/uu/expand" }
expr = { optional=true, version="0.0.9", package="uu_expr", path="src/uu/expr" }
factor = { optional=true, version="0.0.9", package="uu_factor", path="src/uu/factor" }
false = { optional=true, version="0.0.9", package="uu_false", path="src/uu/false" }
fmt = { optional=true, version="0.0.9", package="uu_fmt", path="src/uu/fmt" }
fold = { optional=true, version="0.0.9", package="uu_fold", path="src/uu/fold" }
groups = { optional=true, version="0.0.9", package="uu_groups", path="src/uu/groups" }
hashsum = { optional=true, version="0.0.9", package="uu_hashsum", path="src/uu/hashsum" }
head = { optional=true, version="0.0.9", package="uu_head", path="src/uu/head" }
hostid = { optional=true, version="0.0.9", package="uu_hostid", path="src/uu/hostid" }
hostname = { optional=true, version="0.0.9", package="uu_hostname", path="src/uu/hostname" }
id = { optional=true, version="0.0.9", package="uu_id", path="src/uu/id" }
install = { optional=true, version="0.0.9", package="uu_install", path="src/uu/install" }
join = { optional=true, version="0.0.9", package="uu_join", path="src/uu/join" }
kill = { optional=true, version="0.0.9", package="uu_kill", path="src/uu/kill" }
link = { optional=true, version="0.0.9", package="uu_link", path="src/uu/link" }
ln = { optional=true, version="0.0.9", package="uu_ln", path="src/uu/ln" }
ls = { optional=true, version="0.0.9", package="uu_ls", path="src/uu/ls" }
logname = { optional=true, version="0.0.9", package="uu_logname", path="src/uu/logname" }
mkdir = { optional=true, version="0.0.9", package="uu_mkdir", path="src/uu/mkdir" }
mkfifo = { optional=true, version="0.0.9", package="uu_mkfifo", path="src/uu/mkfifo" }
mknod = { optional=true, version="0.0.9", package="uu_mknod", path="src/uu/mknod" }
mktemp = { optional=true, version="0.0.9", package="uu_mktemp", path="src/uu/mktemp" }
more = { optional=true, version="0.0.9", package="uu_more", path="src/uu/more" }
mv = { optional=true, version="0.0.9", package="uu_mv", path="src/uu/mv" }
nice = { optional=true, version="0.0.9", package="uu_nice", path="src/uu/nice" }
nl = { optional=true, version="0.0.9", package="uu_nl", path="src/uu/nl" }
nohup = { optional=true, version="0.0.9", package="uu_nohup", path="src/uu/nohup" }
nproc = { optional=true, version="0.0.9", package="uu_nproc", path="src/uu/nproc" }
numfmt = { optional=true, version="0.0.9", package="uu_numfmt", path="src/uu/numfmt" }
od = { optional=true, version="0.0.9", package="uu_od", path="src/uu/od" }
paste = { optional=true, version="0.0.9", package="uu_paste", path="src/uu/paste" }
pathchk = { optional=true, version="0.0.9", package="uu_pathchk", path="src/uu/pathchk" }
pinky = { optional=true, version="0.0.9", package="uu_pinky", path="src/uu/pinky" }
pr = { optional=true, version="0.0.9", package="uu_pr", path="src/uu/pr" }
printenv = { optional=true, version="0.0.9", package="uu_printenv", path="src/uu/printenv" }
printf = { optional=true, version="0.0.9", package="uu_printf", path="src/uu/printf" }
ptx = { optional=true, version="0.0.9", package="uu_ptx", path="src/uu/ptx" }
pwd = { optional=true, version="0.0.9", package="uu_pwd", path="src/uu/pwd" }
readlink = { optional=true, version="0.0.9", package="uu_readlink", path="src/uu/readlink" }
realpath = { optional=true, version="0.0.9", package="uu_realpath", path="src/uu/realpath" }
relpath = { optional=true, version="0.0.9", package="uu_relpath", path="src/uu/relpath" }
rm = { optional=true, version="0.0.9", package="uu_rm", path="src/uu/rm" }
rmdir = { optional=true, version="0.0.9", package="uu_rmdir", path="src/uu/rmdir" }
runcon = { optional=true, version="0.0.9", package="uu_runcon", path="src/uu/runcon" }
seq = { optional=true, version="0.0.9", package="uu_seq", path="src/uu/seq" }
shred = { optional=true, version="0.0.9", package="uu_shred", path="src/uu/shred" }
shuf = { optional=true, version="0.0.9", package="uu_shuf", path="src/uu/shuf" }
sleep = { optional=true, version="0.0.9", package="uu_sleep", path="src/uu/sleep" }
sort = { optional=true, version="0.0.9", package="uu_sort", path="src/uu/sort" }
split = { optional=true, version="0.0.9", package="uu_split", path="src/uu/split" }
stat = { optional=true, version="0.0.9", package="uu_stat", path="src/uu/stat" }
stdbuf = { optional=true, version="0.0.9", package="uu_stdbuf", path="src/uu/stdbuf" }
sum = { optional=true, version="0.0.9", package="uu_sum", path="src/uu/sum" }
sync = { optional=true, version="0.0.9", package="uu_sync", path="src/uu/sync" }
tac = { optional=true, version="0.0.9", package="uu_tac", path="src/uu/tac" }
tail = { optional=true, version="0.0.9", package="uu_tail", path="src/uu/tail" }
tee = { optional=true, version="0.0.9", package="uu_tee", path="src/uu/tee" }
timeout = { optional=true, version="0.0.9", package="uu_timeout", path="src/uu/timeout" }
touch = { optional=true, version="0.0.9", package="uu_touch", path="src/uu/touch" }
tr = { optional=true, version="0.0.9", package="uu_tr", path="src/uu/tr" }
true = { optional=true, version="0.0.9", package="uu_true", path="src/uu/true" }
truncate = { optional=true, version="0.0.9", package="uu_truncate", path="src/uu/truncate" }
tsort = { optional=true, version="0.0.9", package="uu_tsort", path="src/uu/tsort" }
tty = { optional=true, version="0.0.9", package="uu_tty", path="src/uu/tty" }
uname = { optional=true, version="0.0.9", package="uu_uname", path="src/uu/uname" }
unexpand = { optional=true, version="0.0.9", package="uu_unexpand", path="src/uu/unexpand" }
uniq = { optional=true, version="0.0.9", package="uu_uniq", path="src/uu/uniq" }
unlink = { optional=true, version="0.0.9", package="uu_unlink", path="src/uu/unlink" }
uptime = { optional=true, version="0.0.9", package="uu_uptime", path="src/uu/uptime" }
users = { optional=true, version="0.0.9", package="uu_users", path="src/uu/users" }
wc = { optional=true, version="0.0.9", package="uu_wc", path="src/uu/wc" }
who = { optional=true, version="0.0.9", package="uu_who", path="src/uu/who" }
whoami = { optional=true, version="0.0.9", package="uu_whoami", path="src/uu/whoami" }
yes = { optional=true, version="0.0.9", package="uu_yes", path="src/uu/yes" }
# this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)"
# factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" }
@ -362,19 +362,19 @@ yes = { optional=true, version="0.0.8", package="uu_yes", path="src/uu/yes"
#pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`)
[dev-dependencies]
chrono = "0.4.11"
chrono = "^0.4.11"
conv = "0.3"
filetime = "0.2"
glob = "0.3.0"
libc = "0.2"
pretty_assertions = "0.7.2"
pretty_assertions = "1"
rand = "0.7"
regex = "1.0"
sha1 = { version="0.6", features=["std"] }
tempfile = "3.2.0"
time = "0.1"
unindent = "0.1"
uucore = { version=">=0.0.10", package="uucore", path="src/uucore", features=["entries", "process"] }
uucore = { version=">=0.0.11", package="uucore", path="src/uucore", features=["entries", "process"] }
walkdir = "2.2"
atty = "0.2"

View file

@ -47,12 +47,12 @@ BUSYBOX_VER := 1.32.1
BUSYBOX_SRC := $(BUSYBOX_ROOT)/busybox-$(BUSYBOX_VER)
ifeq ($(SELINUX_ENABLED),)
SELINUX_ENABLED := 0
ifneq ($(OS),Windows_NT)
ifeq ($(shell /sbin/selinuxenabled 2>/dev/null ; echo $$?),0)
SELINUX_ENABLED := 1
endif
endif
SELINUX_ENABLED := 0
ifneq ($(OS),Windows_NT)
ifeq ($(shell /sbin/selinuxenabled 2>/dev/null ; echo $$?),0)
SELINUX_ENABLED := 1
endif
endif
endif
# Possible programs
@ -161,11 +161,11 @@ SELINUX_PROGS := \
runcon
ifneq ($(OS),Windows_NT)
PROGS := $(PROGS) $(UNIX_PROGS)
PROGS := $(PROGS) $(UNIX_PROGS)
endif
ifeq ($(SELINUX_ENABLED),1)
PROGS := $(PROGS) $(SELINUX_PROGS)
PROGS := $(PROGS) $(SELINUX_PROGS)
endif
UTILS ?= $(PROGS)

View file

@ -39,7 +39,7 @@ to compile anywhere, and this is as good a way as any to try and learn it.
### Rust Version
uutils follows Rust's release channels and is tested against stable, beta and nightly.
The current oldest supported version of the Rust compiler is `1.47`.
The current oldest supported version of the Rust compiler is `1.54`.
On both Windows and Redox, only the nightly version is tested currently.

View file

@ -83,7 +83,7 @@ pub fn main() {
mf.write_all(
format!(
"\tmap.insert(\"{k}\", ({krate}::uumain, {krate}::uu_app));\n",
k = krate[override_prefix.len()..].to_string(),
k = &krate[override_prefix.len()..],
krate = krate
)
.as_bytes(),
@ -92,7 +92,7 @@ pub fn main() {
tf.write_all(
format!(
"#[path=\"{dir}/test_{k}.rs\"]\nmod test_{k};\n",
k = krate[override_prefix.len()..].to_string(),
k = &krate[override_prefix.len()..],
dir = util_tests_dir,
)
.as_bytes(),

View file

@ -1,6 +1,6 @@
[package]
name = "uu_arch"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "arch ~ (uutils) display machine architecture"
@ -17,8 +17,8 @@ path = "src/arch.rs"
[dependencies]
platform-info = "0.2"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "arch"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_base32"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "base32 ~ (uutils) decode/encode input (base32-encoding)"
@ -16,8 +16,8 @@ path = "src/base32.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "base32"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_base64"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "base64 ~ (uutils) decode/encode input (base64-encoding)"
@ -15,8 +15,9 @@ edition = "2018"
path = "src/base64.rs"
[dependencies]
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
clap = { version = "2.33", features = ["wrap_help"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"}
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_basename"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "basename ~ (uutils) display PATHNAME with leading directory components removed"
@ -16,8 +16,8 @@ path = "src/basename.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "basename"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_basenc"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "basenc ~ (uutils) decode/encode input"
@ -16,8 +16,8 @@ path = "src/basenc.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"}
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cat"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "cat ~ (uutils) concatenate and display input"
@ -18,8 +18,8 @@ path = "src/cat.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
thiserror = "1.0"
atty = "0.2"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs", "pipes"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "pipes"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(unix)'.dependencies]
unix_socket = "0.5.0"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chcon"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "chcon ~ (uutils) change file security context"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chgrp"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "chgrp ~ (uutils) change the group ownership of FILE"
@ -16,8 +16,8 @@ path = "src/chgrp.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "chgrp"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chmod"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "chmod ~ (uutils) change mode of FILE"
@ -17,8 +17,8 @@ path = "src/chmod.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
walkdir = "2.2"
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chown"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "chown ~ (uutils) change the ownership of FILE"
@ -16,8 +16,8 @@ path = "src/chown.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "chown"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chroot"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "chroot ~ (uutils) run COMMAND under a new root directory"
@ -16,8 +16,8 @@ path = "src/chroot.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "chroot"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cksum"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "cksum ~ (uutils) display CRC and size of input"
@ -17,8 +17,8 @@ path = "src/cksum.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "cksum"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_comm"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "comm ~ (uutils) compare sorted inputs"
@ -17,8 +17,8 @@ path = "src/comm.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "comm"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cp"
version = "0.0.8"
version = "0.0.9"
authors = [
"Jordy Dickinson <jordy.dickinson@gmail.com>",
"Joshua S. Miller <jsmiller@uchicago.edu>",
@ -24,8 +24,8 @@ filetime = "0.2"
libc = "0.2.85"
quick-error = "1.2.3"
selinux = { version="0.2.3", optional=true }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
walkdir = "2.2"
[target.'cfg(target_os = "linux")'.dependencies]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_csplit"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "csplit ~ (uutils) Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output"
@ -18,8 +18,8 @@ path = "src/csplit.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
thiserror = "1.0"
regex = "1.0.0"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "csplit"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cut"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "cut ~ (uutils) display byte/field columns of input lines"
@ -16,8 +16,8 @@ path = "src/cut.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
memchr = "2"
bstr = "0.2"
atty = "0.2"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_date"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "date ~ (uutils) display or set the current time"
@ -15,10 +15,10 @@ edition = "2018"
path = "src/date.rs"
[dependencies]
chrono = "0.4.4"
chrono = "^0.4.11"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(unix)'.dependencies]
libc = "0.2"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_dd"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "dd ~ (uutils) copy and convert files"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_df"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "df ~ (uutils) display file system information"
@ -17,8 +17,8 @@ path = "src/df.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
number_prefix = "0.4"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["libc", "fsext"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "df"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_dircolors"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "dircolors ~ (uutils) display commands to set LS_COLORS"
@ -17,8 +17,8 @@ path = "src/dircolors.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
glob = "0.3.0"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "dircolors"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_dirname"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "dirname ~ (uutils) display parent directory of PATHNAME"
@ -17,8 +17,8 @@ path = "src/dirname.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "dirname"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_du"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "du ~ (uutils) display disk usage"
@ -15,10 +15,10 @@ edition = "2018"
path = "src/du.rs"
[dependencies]
chrono = "^0.4.11"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
chrono = "0.4"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version="0.3", features=[] }

View file

@ -1,6 +1,6 @@
[package]
name = "uu_echo"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "echo ~ (uutils) display TEXT"
@ -16,8 +16,8 @@ path = "src/echo.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "echo"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_env"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND"
@ -18,8 +18,8 @@ path = "src/env.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
rust-ini = "0.17.0"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "env"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_expand"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "expand ~ (uutils) convert input tabs to spaces"
@ -17,8 +17,8 @@ path = "src/expand.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
unicode-width = "0.1.5"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "expand"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_expr"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "expr ~ (uutils) display the value of EXPRESSION"
@ -20,8 +20,8 @@ libc = "0.2.42"
num-bigint = "0.4.0"
num-traits = "0.2.14"
onig = "~4.3.2"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "expr"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_factor"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "factor ~ (uutils) display the prime factors of each NUMBER"
@ -21,7 +21,7 @@ num-traits = "0.2.13" # Needs at least version 0.2.13 for "OverflowingAdd"
rand = { version = "0.7", features = ["small_rng"] }
smallvec = "1.7" # TODO(nicoo): Use `union` feature, requires Rust 1.49 or later.
uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore" }
uucore_procs = { version=">=0.0.7", package = "uucore_procs", path = "../../uucore_procs" }
uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" }
[dev-dependencies]
paste = "0.1.18"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_false"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "false ~ (uutils) do nothing and fail"
@ -16,8 +16,8 @@ path = "src/false.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "false"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_fmt"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "fmt ~ (uutils) reformat each paragraph of input"
@ -18,8 +18,8 @@ path = "src/fmt.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
unicode-width = "0.1.5"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "fmt"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_fold"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "fold ~ (uutils) wrap each line of input"
@ -16,8 +16,8 @@ path = "src/fold.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "fold"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_groups"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "groups ~ (uutils) display group memberships for USERNAME"
@ -15,9 +15,9 @@ edition = "2018"
path = "src/groups.rs"
[dependencies]
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "groups"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_hashsum"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "hashsum ~ (uutils) display or check input digests"
@ -27,8 +27,8 @@ sha1 = "0.6.0"
sha2 = "0.6.0"
sha3 = "0.6.0"
blake2b_simd = "0.5.11"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "hashsum"

View file

@ -20,7 +20,7 @@ and most other parts of the world.
This particular file has about 170,000 lines, each of which is no longer
than 96 characters:
$ wc -lL shakespeare.txt
$ wc -lL shakespeare.txt
170592 96 shakespeare.txt
You could use files of different shapes and sizes to test the

View file

@ -1,6 +1,6 @@
[package]
name = "uu_head"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "head ~ (uutils) display the first lines of input"
@ -17,8 +17,8 @@ path = "src/head.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
memchr = "2"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["ringbuffer"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "head"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_hostid"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "hostid ~ (uutils) display the numeric identifier of the current host"
@ -17,8 +17,8 @@ path = "src/hostid.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "hostid"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_hostname"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "hostname ~ (uutils) display or set the host name of the current host"
@ -18,8 +18,8 @@ path = "src/hostname.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
hostname = { version = "0.3", features = ["set"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["wide"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
winapi = { version="0.3", features=["sysinfoapi", "winsock2"] }
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_id"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "id ~ (uutils) display user and group information for USER"
@ -16,8 +16,8 @@ path = "src/id.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
selinux = { version="0.2.1", optional = true }
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_install"
version = "0.0.8"
version = "0.0.9"
authors = [
"Ben Eills <ben@beneills.com>",
"uutils developers",
@ -22,8 +22,8 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] }
filetime = "0.2"
file_diff = "1.0.0"
libc = ">= 0.2"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs", "mode", "perms", "entries"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode", "perms", "entries"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[dev-dependencies]
time = "0.1.40"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_join"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "join ~ (uutils) merge lines from inputs with matching join fields"
@ -16,8 +16,8 @@ path = "src/join.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "join"

View file

@ -13,7 +13,7 @@ extern crate uucore;
use clap::{crate_version, App, Arg};
use std::cmp::Ordering;
use std::fs::File;
use std::io::{stdin, BufRead, BufReader, Lines, Stdin};
use std::io::{stdin, stdout, BufRead, BufReader, Split, Stdin, Write};
use uucore::display::Quotable;
use uucore::error::{set_exit_code, UResult, USimpleError};
@ -25,9 +25,16 @@ enum FileNum {
File2,
}
#[repr(u8)]
#[derive(Copy, Clone)]
enum LineEnding {
Nul = 0,
Newline = b'\n',
}
#[derive(Copy, Clone)]
enum Sep {
Char(char),
Char(u8),
Line,
Whitespaces,
}
@ -46,10 +53,11 @@ struct Settings {
print_unpaired2: bool,
print_joined: bool,
ignore_case: bool,
line_ending: LineEnding,
separator: Sep,
autoformat: bool,
format: Vec<Spec>,
empty: String,
empty: Vec<u8>,
check_order: CheckOrder,
headers: bool,
}
@ -63,10 +71,11 @@ impl Default for Settings {
print_unpaired2: false,
print_joined: true,
ignore_case: false,
line_ending: LineEnding::Newline,
separator: Sep::Whitespaces,
autoformat: false,
format: vec![],
empty: String::new(),
empty: vec![],
check_order: CheckOrder::Default,
headers: false,
}
@ -75,14 +84,21 @@ impl Default for Settings {
/// Output representation.
struct Repr<'a> {
separator: char,
line_ending: LineEnding,
separator: u8,
format: &'a [Spec],
empty: &'a str,
empty: &'a [u8],
}
impl<'a> Repr<'a> {
fn new(separator: char, format: &'a [Spec], empty: &'a str) -> Repr<'a> {
fn new(
line_ending: LineEnding,
separator: u8,
format: &'a [Spec],
empty: &'a [u8],
) -> Repr<'a> {
Repr {
line_ending,
separator,
format,
empty,
@ -94,32 +110,34 @@ impl<'a> Repr<'a> {
}
/// Print the field or empty filler if the field is not set.
fn print_field(&self, field: Option<&str>) {
fn print_field(&self, field: Option<&Vec<u8>>) -> Result<(), std::io::Error> {
let value = match field {
Some(field) => field,
None => self.empty,
};
print!("{}", value);
stdout().write_all(value)
}
/// Print each field except the one at the index.
fn print_fields(&self, line: &Line, index: usize) {
fn print_fields(&self, line: &Line, index: usize) -> Result<(), std::io::Error> {
for i in 0..line.fields.len() {
if i != index {
print!("{}{}", self.separator, line.fields[i]);
stdout().write_all(&[self.separator])?;
stdout().write_all(&line.fields[i])?;
}
}
Ok(())
}
/// Print each field or the empty filler if the field is not set.
fn print_format<F>(&self, f: F)
fn print_format<F>(&self, f: F) -> Result<(), std::io::Error>
where
F: Fn(&Spec) -> Option<&'a str>,
F: Fn(&Spec) -> Option<&'a Vec<u8>>,
{
for i in 0..self.format.len() {
if i > 0 {
print!("{}", self.separator);
stdout().write_all(&[self.separator])?;
}
let field = match f(&self.format[i]) {
@ -127,8 +145,13 @@ impl<'a> Repr<'a> {
None => self.empty,
};
print!("{}", field);
stdout().write_all(field)?;
}
Ok(())
}
fn print_line_ending(&self) -> Result<(), std::io::Error> {
stdout().write_all(&[self.line_ending as u8])
}
}
@ -148,10 +171,12 @@ impl Input {
}
}
fn compare(&self, field1: Option<&str>, field2: Option<&str>) -> Ordering {
fn compare(&self, field1: Option<&Vec<u8>>, field2: Option<&Vec<u8>>) -> Ordering {
if let (Some(field1), Some(field2)) = (field1, field2) {
if self.ignore_case {
field1.to_lowercase().cmp(&field2.to_lowercase())
field1
.to_ascii_lowercase()
.cmp(&field2.to_ascii_lowercase())
} else {
field1.cmp(field2)
}
@ -209,14 +234,19 @@ impl Spec {
}
struct Line {
fields: Vec<String>,
fields: Vec<Vec<u8>>,
}
impl Line {
fn new(string: String, separator: Sep) -> Line {
fn new(string: Vec<u8>, separator: Sep) -> Line {
let fields = match separator {
Sep::Whitespaces => string.split_whitespace().map(String::from).collect(),
Sep::Char(sep) => string.split(sep).map(String::from).collect(),
Sep::Whitespaces => string
// GNU join uses Bourne shell field splitters by default
.split(|c| matches!(*c, b' ' | b'\t' | b'\n'))
.filter(|f| !f.is_empty())
.map(Vec::from)
.collect(),
Sep::Char(sep) => string.split(|c| *c == sep).map(Vec::from).collect(),
Sep::Line => vec![string],
};
@ -224,7 +254,7 @@ impl Line {
}
/// Get field at index.
fn get_field(&self, index: usize) -> Option<&str> {
fn get_field(&self, index: usize) -> Option<&Vec<u8>> {
if index < self.fields.len() {
Some(&self.fields[index])
} else {
@ -238,7 +268,7 @@ struct State<'a> {
file_name: &'a str,
file_num: FileNum,
print_unpaired: bool,
lines: Lines<Box<dyn BufRead + 'a>>,
lines: Split<Box<dyn BufRead + 'a>>,
seq: Vec<Line>,
line_num: usize,
has_failed: bool,
@ -250,6 +280,7 @@ impl<'a> State<'a> {
name: &'a str,
stdin: &'a Stdin,
key: usize,
line_ending: LineEnding,
print_unpaired: bool,
) -> State<'a> {
let f = if name == "-" {
@ -266,7 +297,7 @@ impl<'a> State<'a> {
file_name: name,
file_num,
print_unpaired,
lines: f.lines(),
lines: f.split(line_ending as u8),
seq: Vec::new(),
line_num: 0,
has_failed: false,
@ -274,12 +305,13 @@ impl<'a> State<'a> {
}
/// Skip the current unpaired line.
fn skip_line(&mut self, input: &Input, repr: &Repr) {
fn skip_line(&mut self, input: &Input, repr: &Repr) -> Result<(), std::io::Error> {
if self.print_unpaired {
self.print_first_line(repr);
self.print_first_line(repr)?;
}
self.reset_next_line(input);
Ok(())
}
/// Keep reading line sequence until the key does not change, return
@ -299,20 +331,22 @@ impl<'a> State<'a> {
}
/// Print lines in the buffers as headers.
fn print_headers(&self, other: &State, repr: &Repr) {
fn print_headers(&self, other: &State, repr: &Repr) -> Result<(), std::io::Error> {
if self.has_line() {
if other.has_line() {
self.combine(other, repr);
self.combine(other, repr)?;
} else {
self.print_first_line(repr);
self.print_first_line(repr)?;
}
} else if other.has_line() {
other.print_first_line(repr);
other.print_first_line(repr)?;
}
Ok(())
}
/// Combine two line sequences.
fn combine(&self, other: &State, repr: &Repr) {
fn combine(&self, other: &State, repr: &Repr) -> Result<(), std::io::Error> {
let key = self.get_current_key();
for line1 in &self.seq {
@ -331,16 +365,18 @@ impl<'a> State<'a> {
None
}
});
})?;
} else {
repr.print_field(key);
repr.print_fields(line1, self.key);
repr.print_fields(line2, other.key);
repr.print_field(key)?;
repr.print_fields(line1, self.key)?;
repr.print_fields(line2, other.key)?;
}
println!();
repr.print_line_ending()?;
}
}
Ok(())
}
/// Reset with the next line.
@ -377,14 +413,16 @@ impl<'a> State<'a> {
0
}
fn finalize(&mut self, input: &Input, repr: &Repr) {
fn finalize(&mut self, input: &Input, repr: &Repr) -> Result<(), std::io::Error> {
if self.has_line() && self.print_unpaired {
self.print_first_line(repr);
self.print_first_line(repr)?;
while let Some(line) = self.next_line(input) {
self.print_line(&line, repr);
self.print_line(&line, repr)?;
}
}
Ok(())
}
/// Get the next line without the order check.
@ -423,11 +461,11 @@ impl<'a> State<'a> {
}
/// Gets the key value of the lines stored in seq.
fn get_current_key(&self) -> Option<&str> {
fn get_current_key(&self) -> Option<&Vec<u8>> {
self.seq[0].get_field(self.key)
}
fn print_line(&self, line: &Line, repr: &Repr) {
fn print_line(&self, line: &Line, repr: &Repr) -> Result<(), std::io::Error> {
if repr.uses_format() {
repr.print_format(|spec| match *spec {
Spec::Key => line.get_field(self.key),
@ -438,17 +476,17 @@ impl<'a> State<'a> {
None
}
}
});
})?;
} else {
repr.print_field(line.get_field(self.key));
repr.print_fields(line, self.key);
repr.print_field(line.get_field(self.key))?;
repr.print_fields(line, self.key)?;
}
println!();
repr.print_line_ending()
}
fn print_first_line(&self, repr: &Repr) {
self.print_line(&self.seq[0], repr);
fn print_first_line(&self, repr: &Repr) -> Result<(), std::io::Error> {
self.print_line(&self.seq[0], repr)
}
}
@ -481,14 +519,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
settings.key1 = get_field_number(keys, key1)?;
settings.key2 = get_field_number(keys, key2)?;
if let Some(value) = matches.value_of("t") {
if let Some(value_str) = matches.value_of("t") {
let value = value_str.as_bytes();
settings.separator = match value.len() {
0 => Sep::Line,
1 => Sep::Char(value.chars().next().unwrap()),
1 => Sep::Char(value[0]),
_ => {
return Err(USimpleError::new(
1,
format!("multi-character tab {}", value),
format!("multi-character tab {}", value_str),
))
}
};
@ -507,7 +546,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
if let Some(empty) = matches.value_of("e") {
settings.empty = empty.to_string();
settings.empty = empty.as_bytes().to_vec();
}
if matches.is_present("nocheck-order") {
@ -522,6 +561,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
settings.headers = true;
}
if matches.is_present("z") {
settings.line_ending = LineEnding::Nul;
}
let file1 = matches.value_of("file1").unwrap();
let file2 = matches.value_of("file2").unwrap();
@ -529,7 +572,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
return Err(USimpleError::new(1, "both files cannot be standard input"));
}
exec(file1, file2, settings)
match exec(file1, file2, settings) {
Ok(_) => Ok(()),
Err(e) => Err(USimpleError::new(1, format!("{}", e))),
}
}
pub fn uu_app<'a>() -> App<'a> {
@ -623,6 +669,12 @@ FILENUM is 1 or 2, corresponding to FILE1 or FILE2",
"treat the first line in each file as field headers, \
print them without trying to pair them",
))
.arg(
Arg::new("z")
.short('z')
.long("zero-terminated")
.help("line delimiter is NUL, not newline"),
)
.arg(
Arg::new("file1")
.required(true)
@ -637,7 +689,7 @@ FILENUM is 1 or 2, corresponding to FILE1 or FILE2",
)
}
fn exec(file1: &str, file2: &str, settings: Settings) -> UResult<()> {
fn exec(file1: &str, file2: &str, settings: Settings) -> Result<(), std::io::Error> {
let stdin = stdin();
let mut state1 = State::new(
@ -645,6 +697,7 @@ fn exec(file1: &str, file2: &str, settings: Settings) -> UResult<()> {
file1,
&stdin,
settings.key1,
settings.line_ending,
settings.print_unpaired1,
);
@ -653,6 +706,7 @@ fn exec(file1: &str, file2: &str, settings: Settings) -> UResult<()> {
file2,
&stdin,
settings.key2,
settings.line_ending,
settings.print_unpaired2,
);
@ -682,16 +736,17 @@ fn exec(file1: &str, file2: &str, settings: Settings) -> UResult<()> {
};
let repr = Repr::new(
settings.line_ending,
match settings.separator {
Sep::Char(sep) => sep,
_ => ' ',
_ => b' ',
},
&format,
&settings.empty,
);
if settings.headers {
state1.print_headers(&state2, &repr);
state1.print_headers(&state2, &repr)?;
state1.reset_read_line(&input);
state2.reset_read_line(&input);
}
@ -701,17 +756,17 @@ fn exec(file1: &str, file2: &str, settings: Settings) -> UResult<()> {
match diff {
Ordering::Less => {
state1.skip_line(&input, &repr);
state1.skip_line(&input, &repr)?;
}
Ordering::Greater => {
state2.skip_line(&input, &repr);
state2.skip_line(&input, &repr)?;
}
Ordering::Equal => {
let next_line1 = state1.extend(&input);
let next_line2 = state2.extend(&input);
if settings.print_joined {
state1.combine(&state2, &repr);
state1.combine(&state2, &repr)?;
}
state1.reset(next_line1);
@ -720,8 +775,8 @@ fn exec(file1: &str, file2: &str, settings: Settings) -> UResult<()> {
}
}
state1.finalize(&input, &repr);
state2.finalize(&input, &repr);
state1.finalize(&input, &repr)?;
state2.finalize(&input, &repr)?;
if state1.has_failed || state2.has_failed {
set_exit_code(1);

View file

@ -1,6 +1,6 @@
[package]
name = "uu_kill"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "kill ~ (uutils) send a signal to a process"
@ -17,8 +17,8 @@ path = "src/kill.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["signals"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "kill"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_link"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "link ~ (uutils) create a hard (file system) link to FILE"
@ -16,9 +16,9 @@ path = "src/link.rs"
[dependencies]
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "link"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_ln"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "ln ~ (uutils) create a (file system) link to TARGET"
@ -17,8 +17,8 @@ path = "src/ln.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "ln"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_logname"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "logname ~ (uutils) display the login name of the current user"
@ -17,8 +17,8 @@ path = "src/logname.rs"
[dependencies]
libc = "0.2.42"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "logname"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_ls"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "ls ~ (uutils) display directory contents"
@ -24,7 +24,7 @@ termsize = "0.1.6"
glob = "0.3.0"
lscolors = { version = "0.7.1", features = ["ansi_term"] }
uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore", features = ["entries", "fs"] }
uucore_procs = { version=">=0.0.7", package = "uucore_procs", path = "../../uucore_procs" }
uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" }
once_cell = "1.7.2"
atty = "0.2"
selinux = { version="0.2.1", optional = true }

View file

@ -319,6 +319,10 @@ struct PaddingCollection {
longest_group_len: usize,
longest_context_len: usize,
longest_size_len: usize,
#[cfg(unix)]
longest_major_len: usize,
#[cfg(unix)]
longest_minor_len: usize,
}
impl Config {
@ -1561,18 +1565,28 @@ fn display_dir_entry_size(
entry: &PathData,
config: &Config,
out: &mut BufWriter<std::io::Stdout>,
) -> (usize, usize, usize, usize, usize) {
) -> (usize, usize, usize, usize, usize, usize, usize) {
// TODO: Cache/memorize the display_* results so we don't have to recalculate them.
if let Some(md) = entry.md(out) {
let (size_len, major_len, minor_len) = match display_size_or_rdev(md, config) {
SizeOrDeviceId::Device(major, minor) => (
(major.len() + minor.len() + 2usize),
major.len(),
minor.len(),
),
SizeOrDeviceId::Size(size) => (size.len(), 0usize, 0usize),
};
(
display_symlink_count(md).len(),
display_uname(md, config).len(),
display_group(md, config).len(),
display_size_or_rdev(md, config).len(),
size_len,
major_len,
minor_len,
display_inode(md).len(),
)
} else {
(0, 0, 0, 0, 0)
(0, 0, 0, 0, 0, 0, 0)
}
}
@ -1609,7 +1623,9 @@ fn display_items(items: &[PathData], config: &Config, out: &mut BufWriter<Stdout
mut longest_group_len,
mut longest_context_len,
mut longest_size_len,
) = (1, 1, 1, 1, 1, 1);
mut longest_major_len,
mut longest_minor_len,
) = (1, 1, 1, 1, 1, 1, 1, 1);
#[cfg(not(unix))]
let (
@ -1623,26 +1639,41 @@ fn display_items(items: &[PathData], config: &Config, out: &mut BufWriter<Stdout
#[cfg(unix)]
for item in items {
let context_len = item.security_context.len();
let (link_count_len, uname_len, group_len, size_len, inode_len) =
let (link_count_len, uname_len, group_len, size_len, major_len, minor_len, inode_len) =
display_dir_entry_size(item, config, out);
longest_inode_len = inode_len.max(longest_inode_len);
longest_link_count_len = link_count_len.max(longest_link_count_len);
longest_size_len = size_len.max(longest_size_len);
longest_uname_len = uname_len.max(longest_uname_len);
longest_group_len = group_len.max(longest_group_len);
if config.context {
longest_context_len = context_len.max(longest_context_len);
}
longest_size_len = size_len.max(longest_size_len);
if items.len() == 1usize {
longest_size_len = 0usize;
longest_major_len = 0usize;
longest_minor_len = 0usize;
} else {
longest_major_len = major_len.max(longest_major_len);
longest_minor_len = minor_len.max(longest_minor_len);
longest_size_len = size_len
.max(longest_size_len)
.max(longest_major_len + longest_minor_len + 2usize);
}
}
#[cfg(not(unix))]
for item in items {
let context_len = item.security_context.len();
let (link_count_len, uname_len, group_len, size_len, _inode_len) =
display_dir_entry_size(item, config, out);
let (
link_count_len,
uname_len,
group_len,
size_len,
_major_len,
_minor_len,
_inode_len,
) = display_dir_entry_size(item, config, out);
longest_link_count_len = link_count_len.max(longest_link_count_len);
longest_size_len = size_len.max(longest_size_len);
longest_uname_len = uname_len.max(longest_uname_len);
longest_group_len = group_len.max(longest_group_len);
if config.context {
@ -1662,6 +1693,10 @@ fn display_items(items: &[PathData], config: &Config, out: &mut BufWriter<Stdout
longest_group_len,
longest_context_len,
longest_size_len,
#[cfg(unix)]
longest_major_len,
#[cfg(unix)]
longest_minor_len,
},
config,
out,
@ -1679,9 +1714,25 @@ fn display_items(items: &[PathData], config: &Config, out: &mut BufWriter<Stdout
None
};
#[cfg(not(unix))]
let longest_inode_len = 1;
#[cfg(unix)]
let mut longest_inode_len = 1;
#[cfg(unix)]
if config.inode {
for item in items {
let inode_len = if let Some(md) = item.md(out) {
display_inode(md).len()
} else {
continue;
};
longest_inode_len = inode_len.max(longest_inode_len);
}
}
let names: std::vec::IntoIter<Cell> = items
.iter()
.map(|i| display_file_name(i, config, prefix_context, out))
.map(|i| display_file_name(i, config, prefix_context, longest_inode_len, out))
.collect::<Vec<Cell>>()
.into_iter();
@ -1879,17 +1930,41 @@ fn display_item_long(
);
}
let dfn = display_file_name(item, config, None, out).contents;
match display_size_or_rdev(md, config) {
SizeOrDeviceId::Size(size) => {
let _ = write!(out, " {}", pad_left(&size, padding.longest_size_len),);
}
SizeOrDeviceId::Device(major, minor) => {
let _ = write!(
out,
" {}, {}",
pad_left(
&major,
#[cfg(not(unix))]
0usize,
#[cfg(unix)]
padding.longest_major_len.max(
padding
.longest_size_len
.saturating_sub(padding.longest_minor_len.saturating_add(2usize))
)
),
pad_left(
&minor,
#[cfg(not(unix))]
0usize,
#[cfg(unix)]
padding.longest_minor_len,
),
);
}
};
let _ = writeln!(
out,
" {} {} {}",
pad_left(&display_size_or_rdev(md, config), padding.longest_size_len),
display_date(md, config),
dfn,
);
let dfn = display_file_name(item, config, None, 0, out).contents;
let _ = writeln!(out, " {} {}", display_date(md, config), dfn);
} else {
// this 'else' is expressly for the case of a dangling symlink
// this 'else' is expressly for the case of a dangling symlink/restricted file
#[cfg(unix)]
{
if config.inode {
@ -1900,7 +1975,7 @@ fn display_item_long(
let _ = write!(
out,
"{}{} {}",
"l?????????".to_string(),
"l?????????",
if item.security_context.len() > 1 {
// GNU `ls` uses a "." character to indicate a file with a security context,
// but not other alternate access method.
@ -1933,7 +2008,7 @@ fn display_item_long(
let _ = write!(out, " {}", pad_right("?", padding.longest_uname_len));
}
let dfn = display_file_name(item, config, None, out).contents;
let dfn = display_file_name(item, config, None, 0, out).contents;
let date_len = 12;
let _ = writeln!(
@ -2097,19 +2172,35 @@ fn format_prefixed(prefixed: NumberPrefix<f64>) -> String {
}
}
fn display_size_or_rdev(metadata: &Metadata, config: &Config) -> String {
#[cfg(unix)]
#[allow(dead_code)]
enum SizeOrDeviceId {
Size(String),
Device(String, String),
}
fn display_size_or_rdev(metadata: &Metadata, config: &Config) -> SizeOrDeviceId {
#[cfg(any(target_os = "macos", target_os = "ios"))]
{
let ft = metadata.file_type();
if ft.is_char_device() || ft.is_block_device() {
let dev: u64 = metadata.rdev();
let major = (dev >> 24) as u8;
let minor = (dev & 0xff) as u8;
return SizeOrDeviceId::Device(major.to_string(), minor.to_string());
}
}
#[cfg(target_os = "linux")]
{
let ft = metadata.file_type();
if ft.is_char_device() || ft.is_block_device() {
let dev: u64 = metadata.rdev();
let major = (dev >> 8) as u8;
let minor = dev as u8;
return format!("{}, {}", major, minor,);
let minor = (dev & 0xff) as u8;
return SizeOrDeviceId::Device(major.to_string(), minor.to_string());
}
}
display_size(metadata.len(), config)
SizeOrDeviceId::Size(display_size(metadata.len(), config))
}
fn display_size(size: u64, config: &Config) -> String {
@ -2175,6 +2266,7 @@ fn display_file_name(
path: &PathData,
config: &Config,
prefix_context: Option<usize>,
longest_inode_len: usize,
out: &mut BufWriter<Stdout>,
) -> Cell {
// This is our return value. We start by `&path.display_name` and modify it along the way.
@ -2194,8 +2286,8 @@ fn display_file_name(
{
if config.inode && config.format != Format::Long {
let inode = match path.md(out) {
Some(md) => get_inode(md),
None => "?".to_string(),
Some(md) => pad_left(&get_inode(md), longest_inode_len),
None => pad_left("?", longest_inode_len),
};
// increment width here b/c name was given colors and name.width() is now the wrong
// size for display

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mkdir"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "mkdir ~ (uutils) create DIRECTORY"
@ -17,8 +17,8 @@ path = "src/mkdir.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mkdir"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mkfifo"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "mkfifo ~ (uutils) create FIFOs (named pipes)"
@ -17,8 +17,8 @@ path = "src/mkfifo.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mkfifo"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mknod"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "mknod ~ (uutils) create special file NAME of TYPE"
@ -18,8 +18,8 @@ path = "src/mknod.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "^0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["mode"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mknod"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mktemp"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "mktemp ~ (uutils) create and display a temporary file or directory from TEMPLATE"
@ -18,8 +18,8 @@ path = "src/mktemp.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
rand = "0.5"
tempfile = "3.1"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mktemp"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_more"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "more ~ (uutils) input perusal filter"
@ -17,7 +17,7 @@ path = "src/more.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version = ">=0.0.7", package = "uucore", path = "../../uucore" }
uucore_procs = { version=">=0.0.7", package = "uucore_procs", path = "../../uucore_procs" }
uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" }
crossterm = ">=0.19"
atty = "0.2"
unicode-width = "0.1.7"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mv"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "mv ~ (uutils) move (rename) SOURCE to DESTINATION"
@ -17,8 +17,8 @@ path = "src/mv.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
fs_extra = "1.1.0"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "mv"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_nice"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "nice ~ (uutils) run PROGRAM with modified scheduling priority"
@ -18,8 +18,8 @@ path = "src/nice.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
nix = "0.23.1"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nice"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_nl"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "nl ~ (uutils) display input with added line numbers"
@ -21,12 +21,12 @@ libc = "0.2.42"
memchr = "2.2.0"
regex = "1.0.1"
regex-syntax = "0.6.7"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nl"
path = "src/main.rs"
[package.metadata.cargo-udeps.ignore]
normal = ["uucore_procs"]
normal = ["uucore_procs"]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_nohup"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "nohup ~ (uutils) run COMMAND, ignoring hangup signals"
@ -18,8 +18,8 @@ path = "src/nohup.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
atty = "0.2"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nohup"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_nproc"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "nproc ~ (uutils) display the number of processing units available"
@ -18,8 +18,8 @@ path = "src/nproc.rs"
libc = "0.2.42"
num_cpus = "1.10"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "nproc"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_numfmt"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "numfmt ~ (uutils) reformat NUMBER"
@ -16,12 +16,12 @@ path = "src/numfmt.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "numfmt"
path = "src/main.rs"
[package.metadata.cargo-udeps.ignore]
normal = ["uucore_procs"]
normal = ["uucore_procs"]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_od"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "od ~ (uutils) display formatted representation of input"
@ -19,8 +19,8 @@ byteorder = "1.3.2"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
half = "1.6"
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "od"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_paste"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "paste ~ (uutils) merge lines from inputs"
@ -16,8 +16,8 @@ path = "src/paste.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "paste"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_pathchk"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "pathchk ~ (uutils) diagnose invalid or non-portable PATHNAME"
@ -17,8 +17,8 @@ path = "src/pathchk.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "pathchk"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_pinky"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "pinky ~ (uutils) display user information"
@ -15,9 +15,9 @@ edition = "2018"
path = "src/pinky.rs"
[dependencies]
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["utmpx", "entries"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx", "entries"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "pinky"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_pr"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "pr ~ (uutils) convert text files for printing"
@ -17,7 +17,7 @@ path = "src/pr.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
getopts = "0.2.21"
chrono = "0.4.19"
quick-error = "2.0.1"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_printenv"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "printenv ~ (uutils) display value of environment VAR"
@ -16,8 +16,8 @@ path = "src/printenv.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "printenv"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_printf"
version = "0.0.8"
version = "0.0.9"
authors = [
"Nathan Ross",
"uutils developers",
@ -20,8 +20,8 @@ path = "src/printf.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
itertools = "0.8.0"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "printf"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_ptx"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "ptx ~ (uutils) display a permuted index of input"
@ -21,8 +21,8 @@ libc = "0.2.42"
memchr = "2.2.0"
regex = "1.0.1"
regex-syntax = "0.6.7"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "ptx"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_pwd"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "pwd ~ (uutils) display current working directory"
@ -16,8 +16,8 @@ path = "src/pwd.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "pwd"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_readlink"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "readlink ~ (uutils) display resolved path of PATHNAME"
@ -17,8 +17,8 @@ path = "src/readlink.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "readlink"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_realpath"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "realpath ~ (uutils) display resolved absolute path of PATHNAME"
@ -16,8 +16,8 @@ path = "src/realpath.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "realpath"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_relpath"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "relpath ~ (uutils) display relative path of PATHNAME_TO from PATHNAME_FROM"
@ -16,8 +16,8 @@ path = "src/relpath.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "relpath"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_rm"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "rm ~ (uutils) remove PATHNAME"
@ -18,8 +18,8 @@ path = "src/rm.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
walkdir = "2.2"
remove_dir_all = "0.5.1"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(windows)'.dependencies]
winapi = { version="0.3", features=[] }

View file

@ -217,7 +217,7 @@ pub fn uu_app<'a>() -> App<'a> {
// This is solely for testing.
// Do not document.
// It is relatively difficult to ensure that there is a tty on stdin.
// Since rm acts differently depending on that, without this option,
// Since rm acts differently depending on that, without this option,
// it'd be harder to test the parts of rm that depend on that setting.
.arg(
Arg::new(PRESUME_INPUT_TTY)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_rmdir"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "rmdir ~ (uutils) remove empty DIRECTORY"
@ -16,8 +16,8 @@ path = "src/rmdir.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
libc = "0.2.42"
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_runcon"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "runcon ~ (uutils) run command with specified security context"

View file

@ -1,7 +1,7 @@
# spell-checker:ignore bigdecimal
[package]
name = "uu_seq"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "seq ~ (uutils) display a sequence of numbers"
@ -20,8 +20,8 @@ bigdecimal = "0.3"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
num-bigint = "0.4.0"
num-traits = "0.2.14"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "seq"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_shred"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "shred ~ (uutils) hide former FILE contents with repeated overwrites"
@ -18,8 +18,8 @@ path = "src/shred.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
rand = "0.7"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "shred"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_shuf"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "shuf ~ (uutils) display random permutations of input lines"
@ -17,8 +17,8 @@ path = "src/shuf.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
rand = "0.5"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "shuf"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_sleep"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "sleep ~ (uutils) pause for DURATION"
@ -16,8 +16,8 @@ path = "src/sleep.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "sleep"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_sort"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "sort ~ (uutils) sort input lines"
@ -27,8 +27,8 @@ rand = "0.7"
rayon = "1.5"
tempfile = "3"
unicode-width = "0.1.8"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "sort"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_split"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "split ~ (uutils) split input into output files"
@ -16,8 +16,8 @@ path = "src/split.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "split"

View file

@ -0,0 +1,529 @@
// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore zaaa zaab zzaaaa zzzaaaaa
//! Compute filenames from a given index.
//!
//! The [`FilenameFactory`] can be used to convert a chunk index given
//! as a [`usize`] to a filename for that chunk.
//!
//! # Examples
//!
//! Create filenames of the form `chunk_??.txt`:
//!
//! ```rust,ignore
//! use crate::filenames::FilenameFactory;
//!
//! let prefix = "chunk_".to_string();
//! let suffix = ".txt".to_string();
//! let width = 2;
//! let use_numeric_suffix = false;
//! let factory = FilenameFactory::new(prefix, suffix, width, use_numeric_suffix);
//!
//! assert_eq!(factory.make(0).unwrap(), "chunk_aa.txt");
//! assert_eq!(factory.make(10).unwrap(), "chunk_ak.txt");
//! assert_eq!(factory.make(28).unwrap(), "chunk_bc.txt");
//! ```
/// Base 10 logarithm.
fn log10(n: usize) -> usize {
(n as f64).log10() as usize
}
/// Base 26 logarithm.
fn log26(n: usize) -> usize {
(n as f64).log(26.0) as usize
}
/// Convert a radix 10 number to a radix 26 number of the given width.
///
/// `n` is the radix 10 (that is, decimal) number to transform. This
/// function returns a [`Vec`] of unsigned integers representing the
/// digits, with the most significant digit first and the least
/// significant digit last. The returned `Vec` is always of length
/// `width`.
///
/// If the number `n` is too large to represent within `width` digits,
/// then this function returns `None`.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::to_radix_26;
///
/// assert_eq!(to_radix_26(20, 2), Some(vec![0, 20]));
/// assert_eq!(to_radix_26(26, 2), Some(vec![1, 0]));
/// assert_eq!(to_radix_26(30, 2), Some(vec![1, 4]));
/// ```
fn to_radix_26(mut n: usize, width: usize) -> Option<Vec<u8>> {
if width == 0 {
return None;
}
// Use the division algorithm to repeatedly compute the quotient
// and remainder of the number after division by the radix 26. The
// successive quotients are the digits in radix 26, from most
// significant to least significant.
let mut result = vec![];
for w in (0..width).rev() {
let divisor = 26_usize.pow(w as u32);
let (quotient, remainder) = (n / divisor, n % divisor);
n = remainder;
// If the quotient is equal to or greater than the radix, that
// means the number `n` requires a greater width to be able to
// represent it in radix 26.
if quotient >= 26 {
return None;
}
result.push(quotient as u8);
}
Some(result)
}
/// Convert a number between 0 and 25 into a lowercase ASCII character.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::to_ascii_char;
///
/// assert_eq!(to_ascii_char(&0), Some('a'));
/// assert_eq!(to_ascii_char(&25), Some('z'));
/// assert_eq!(to_ascii_char(&26), None);
/// ```
fn to_ascii_char(n: &u8) -> Option<char> {
// TODO In Rust v1.52.0 or later, use `char::from_digit`:
// https://doc.rust-lang.org/std/primitive.char.html#method.from_digit
//
// char::from_digit(*n as u32 + 10, 36)
//
// In that call, radix 36 is used because the characters in radix
// 36 are [0-9a-z]. We want to exclude the the first ten of those
// characters, so we add 10 to the number before conversion.
//
// Until that function is available, just add `n` to `b'a'` and
// cast to `char`.
if *n < 26 {
Some((b'a' + n) as char)
} else {
None
}
}
/// Fixed width alphabetic string representation of index `i`.
///
/// If `i` is greater than or equal to the number of lowercase ASCII
/// strings that can be represented in the given `width`, then this
/// function returns `None`.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::str_prefix_fixed_width;
///
/// assert_eq!(str_prefix_fixed_width(0, 2).as_deref(), "aa");
/// assert_eq!(str_prefix_fixed_width(675, 2).as_deref(), "zz");
/// assert_eq!(str_prefix_fixed_width(676, 2), None);
/// ```
fn str_prefix_fixed_width(i: usize, width: usize) -> Option<String> {
to_radix_26(i, width)?.iter().map(to_ascii_char).collect()
}
/// Dynamically sized alphabetic string representation of index `i`.
///
/// The size of the returned string starts at two then grows by 2 if
/// `i` is sufficiently large.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::str_prefix;
///
/// assert_eq!(str_prefix(0), "aa");
/// assert_eq!(str_prefix(649), "yz");
/// assert_eq!(str_prefix(650), "zaaa");
/// assert_eq!(str_prefix(651), "zaab");
/// ```
fn str_prefix(i: usize) -> Option<String> {
// This number tells us the order of magnitude of `i`, with a
// slight adjustment.
//
// We shift by 26 so that
//
// * if `i` is in the interval [0, 26^2 - 26), then `d` is 1,
// * if `i` is in the interval [26^2 - 26, 26^3 - 26), then `d` is 2,
// * if `i` is in the interval [26^3 - 26, 26^4 - 26), then `d` is 3,
//
// and so on. This will allow us to compute how many leading "z"
// characters need to appear in the string and how many characters
// to format to the right of those.
let d = log26(i + 26);
// This is the number of leading "z" characters.
//
// For values of `i` less than 26^2 - 26, the returned string is
// just the radix 26 representation of that number with a width of
// two (using the lowercase ASCII characters as the digits).
//
// * if `i` is 26^2 - 26, then the returned string is "zaa",
// * if `i` is 26^3 - 26, then the returned string is "zzaaaa",
// * if `i` is 26^4 - 26, then the returned string is "zzzaaaaa",
//
// and so on. As you can see, the number of leading "z"s there is
// linearly increasing by 1 for each order of magnitude.
let num_fill_chars = d - 1;
// This is the number of characters after the leading "z" characters.
let width = d + 1;
// This is the radix 10 number to render in radix 26, to the right
// of the leading "z"s.
let number = (i + 26) - 26_usize.pow(d as u32);
// This is the radix 26 number to render after the leading "z"s,
// collected in a `String`.
//
// For example, if `i` is 789, then `number` is 789 + 26 - 676,
// which equals 139. In radix 26 and assuming a `width` of 3, this
// number is
//
// [0, 5, 9]
//
// with the most significant digit on the left and the least
// significant digit on the right. After translating to ASCII
// lowercase letters, this becomes "afj".
let digits = str_prefix_fixed_width(number, width)?;
// `empty` is just the empty string, to be displayed with a width
// of `num_fill_chars` and with blank spaces filled with the
// character "z".
//
// `digits` is as described in the previous comment.
Some(format!(
"{empty:z<num_fill_chars$}{digits}",
empty = "",
num_fill_chars = num_fill_chars,
digits = digits
))
}
/// Fixed width numeric string representation of index `i`.
///
/// If `i` is greater than or equal to the number of numbers that can
/// be represented in the given `width`, then this function returns
/// `None`.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::num_prefix_fixed_width;
///
/// assert_eq!(num_prefix_fixed_width(0, 2).as_deref(), "89");
/// assert_eq!(num_prefix_fixed_width(99, 2).as_deref(), "9000");
/// assert_eq!(num_prefix_fixed_width(100, 2), None);
/// ```
fn num_prefix_fixed_width(i: usize, width: usize) -> Option<String> {
let max = 10_usize.pow(width as u32);
if i >= max {
None
} else {
Some(format!("{i:0width$}", i = i, width = width))
}
}
/// Dynamically sized numeric string representation of index `i`.
///
/// The size of the returned string starts at two then grows by 2 if
/// `i` is sufficiently large.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::num_prefix;
///
/// assert_eq!(num_prefix(89), "89");
/// assert_eq!(num_prefix(90), "9000");
/// assert_eq!(num_prefix(91), "9001");
/// ```
fn num_prefix(i: usize) -> String {
// This number tells us the order of magnitude of `i`, with a
// slight adjustment.
//
// We shift by 10 so that
//
// * if `i` is in the interval [0, 90), then `d` is 1,
// * if `i` is in the interval [90, 990), then `d` is 2,
// * if `i` is in the interval [990, 9990), then `d` is 3,
//
// and so on. This will allow us to compute how many leading "9"
// characters need to appear in the string and how many digits to
// format to the right of those.
let d = log10(i + 10);
// This is the number of leading "9" characters.
//
// For values of `i` less than 90, the returned string is just
// that number padded by a 0 to ensure the width is 2, but
//
// * if `i` is 90, then the returned string is "900",
// * if `i` is 990, then the returned string is "990000",
// * if `i` is 9990, then the returned string is "99900000",
//
// and so on. As you can see, the number of leading 9s there is
// linearly increasing by 1 for each order of magnitude.
let num_fill_chars = d - 1;
// This is the number of characters after the leading "9" characters.
let width = d + 1;
// This is the number to render after the leading "9"s.
//
// For example, if `i` is 5732, then the returned string is
// "994742". After the two "9" characters is the number 4742,
// which equals 5732 + 10 - 1000.
let number = (i + 10) - 10_usize.pow(d as u32);
// `empty` is just the empty string, to be displayed with a width
// of `num_fill_chars` and with blank spaces filled with the
// character "9".
//
// `number` is the next remaining part of the number to render;
// for small numbers we pad with 0 and enforce a minimum width.
format!(
"{empty:9<num_fill_chars$}{number:0width$}",
empty = "",
num_fill_chars = num_fill_chars,
number = number,
width = width
)
}
/// Compute filenames from a given index.
///
/// The [`FilenameFactory`] can be used to convert a chunk index given
/// as a [`usize`] to a filename for that chunk.
///
/// The general form of filenames produced by instances of this struct is
///
/// ```ignore
/// {prefix}{suffix}{additional_suffix}
/// ```
///
/// If `suffix_length` is a positive integer, then the `suffix`
/// portion will be of exactly that length. If `suffix_length` is 0,
/// then the length of the `suffix` portion will grow dynamically to
/// accommodate any chunk index. In that case, the length begins at 2
/// and increases by 2 when the chunk index becomes sufficiently
/// large.
///
/// If `use_numeric_suffix` is `true`, then the `suffix` portion will
/// be nonnegative integers. If `false`, then the `suffix` will
/// comprise lowercase ASCII characters.
///
/// # Examples
///
/// Create filenames of the form `chunk_??.txt`:
///
/// ```rust,ignore
/// use crate::filenames::FilenameFactory;
///
/// let prefix = "chunk_".to_string();
/// let suffix = ".txt".to_string();
/// let width = 2;
/// let use_numeric_suffix = false;
/// let factory = FilenameFactory::new(prefix, suffix, width, use_numeric_suffix);
///
/// assert_eq!(factory.make(0).unwrap(), "chunk_aa.txt");
/// assert_eq!(factory.make(10).unwrap(), "chunk_ak.txt");
/// assert_eq!(factory.make(28).unwrap(), "chunk_bc.txt");
/// ```
///
/// Set `suffix_length` to 0 for filename sizes that grow dynamically:
///
/// ```rust,ignore
/// use crate::filenames::FilenameFactory;
///
/// let prefix = String::new();
/// let suffix = String::new();
/// let width = 0;
/// let use_numeric_suffix = false;
/// let factory = FilenameFactory::new(prefix, suffix, width, use_numeric_suffix);
///
/// assert_eq!(factory.make(0).unwrap(), "aa");
/// assert_eq!(factory.make(1).unwrap(), "ab");
/// assert_eq!(factory.make(649).unwrap(), "yz");
/// assert_eq!(factory.make(650).unwrap(), "zaaa");
/// assert_eq!(factory.make(6551).unwrap(), "zaab");
/// ```
pub struct FilenameFactory {
additional_suffix: String,
prefix: String,
suffix_length: usize,
use_numeric_suffix: bool,
}
impl FilenameFactory {
/// Create a new instance of this struct.
///
/// For an explanation of the parameters, see the struct documentation.
pub fn new(
prefix: String,
additional_suffix: String,
suffix_length: usize,
use_numeric_suffix: bool,
) -> FilenameFactory {
FilenameFactory {
prefix,
additional_suffix,
suffix_length,
use_numeric_suffix,
}
}
/// Construct the filename for the specified element of the output collection of files.
///
/// For an explanation of the parameters, see the struct documentation.
///
/// If `suffix_length` has been set to a positive integer and `i`
/// is greater than or equal to the number of strings that can be
/// represented within that length, then this returns `None`. For
/// example:
///
/// ```rust,ignore
/// use crate::filenames::FilenameFactory;
///
/// let prefix = String::new();
/// let suffix = String::new();
/// let width = 1;
/// let use_numeric_suffix = true;
/// let factory = FilenameFactory::new(prefix, suffix, width, use_numeric_suffix);
///
/// assert_eq!(factory.make(10), None);
/// ```
pub fn make(&self, i: usize) -> Option<String> {
let prefix = self.prefix.clone();
let suffix1 = match (self.use_numeric_suffix, self.suffix_length) {
(true, 0) => Some(num_prefix(i)),
(false, 0) => str_prefix(i),
(true, width) => num_prefix_fixed_width(i, width),
(false, width) => str_prefix_fixed_width(i, width),
}?;
let suffix2 = &self.additional_suffix;
Some(prefix + &suffix1 + suffix2)
}
}
#[cfg(test)]
mod tests {
use crate::filenames::num_prefix;
use crate::filenames::num_prefix_fixed_width;
use crate::filenames::str_prefix;
use crate::filenames::str_prefix_fixed_width;
use crate::filenames::to_ascii_char;
use crate::filenames::to_radix_26;
use crate::filenames::FilenameFactory;
#[test]
fn test_to_ascii_char() {
assert_eq!(to_ascii_char(&0), Some('a'));
assert_eq!(to_ascii_char(&5), Some('f'));
assert_eq!(to_ascii_char(&25), Some('z'));
assert_eq!(to_ascii_char(&26), None);
}
#[test]
fn test_to_radix_26_exceed_width() {
assert_eq!(to_radix_26(1, 0), None);
assert_eq!(to_radix_26(26, 1), None);
assert_eq!(to_radix_26(26 * 26, 2), None);
}
#[test]
fn test_to_radix_26_width_one() {
assert_eq!(to_radix_26(0, 1), Some(vec![0]));
assert_eq!(to_radix_26(10, 1), Some(vec![10]));
assert_eq!(to_radix_26(20, 1), Some(vec![20]));
assert_eq!(to_radix_26(25, 1), Some(vec![25]));
}
#[test]
fn test_to_radix_26_width_two() {
assert_eq!(to_radix_26(0, 2), Some(vec![0, 0]));
assert_eq!(to_radix_26(10, 2), Some(vec![0, 10]));
assert_eq!(to_radix_26(20, 2), Some(vec![0, 20]));
assert_eq!(to_radix_26(25, 2), Some(vec![0, 25]));
assert_eq!(to_radix_26(26, 2), Some(vec![1, 0]));
assert_eq!(to_radix_26(30, 2), Some(vec![1, 4]));
assert_eq!(to_radix_26(26 * 2, 2), Some(vec![2, 0]));
assert_eq!(to_radix_26(26 * 26 - 1, 2), Some(vec![25, 25]));
}
#[test]
fn test_str_prefix_dynamic_width() {
assert_eq!(str_prefix(0).as_deref(), Some("aa"));
assert_eq!(str_prefix(1).as_deref(), Some("ab"));
assert_eq!(str_prefix(2).as_deref(), Some("ac"));
assert_eq!(str_prefix(25).as_deref(), Some("az"));
assert_eq!(str_prefix(26).as_deref(), Some("ba"));
assert_eq!(str_prefix(27).as_deref(), Some("bb"));
assert_eq!(str_prefix(28).as_deref(), Some("bc"));
assert_eq!(str_prefix(51).as_deref(), Some("bz"));
assert_eq!(str_prefix(52).as_deref(), Some("ca"));
assert_eq!(str_prefix(26 * 25 - 1).as_deref(), Some("yz"));
assert_eq!(str_prefix(26 * 25).as_deref(), Some("zaaa"));
assert_eq!(str_prefix(26 * 25 + 1).as_deref(), Some("zaab"));
}
#[test]
fn test_num_prefix_dynamic_width() {
assert_eq!(num_prefix(0), "00");
assert_eq!(num_prefix(9), "09");
assert_eq!(num_prefix(17), "17");
assert_eq!(num_prefix(89), "89");
assert_eq!(num_prefix(90), "9000");
assert_eq!(num_prefix(91), "9001");
assert_eq!(num_prefix(989), "9899");
assert_eq!(num_prefix(990), "990000");
}
#[test]
fn test_str_prefix_fixed_width() {
assert_eq!(str_prefix_fixed_width(0, 2).as_deref(), Some("aa"));
assert_eq!(str_prefix_fixed_width(1, 2).as_deref(), Some("ab"));
assert_eq!(str_prefix_fixed_width(26, 2).as_deref(), Some("ba"));
assert_eq!(
str_prefix_fixed_width(26 * 26 - 1, 2).as_deref(),
Some("zz")
);
assert_eq!(str_prefix_fixed_width(26 * 26, 2).as_deref(), None);
}
#[test]
fn test_num_prefix_fixed_width() {
assert_eq!(num_prefix_fixed_width(0, 2).as_deref(), Some("00"));
assert_eq!(num_prefix_fixed_width(1, 2).as_deref(), Some("01"));
assert_eq!(num_prefix_fixed_width(99, 2).as_deref(), Some("99"));
assert_eq!(num_prefix_fixed_width(100, 2).as_deref(), None);
}
#[test]
fn test_alphabetic_suffix() {
let factory = FilenameFactory::new("123".to_string(), "789".to_string(), 3, false);
assert_eq!(factory.make(0).unwrap(), "123aaa789");
assert_eq!(factory.make(1).unwrap(), "123aab789");
assert_eq!(factory.make(28).unwrap(), "123abc789");
}
#[test]
fn test_numeric_suffix() {
let factory = FilenameFactory::new("abc".to_string(), "xyz".to_string(), 3, true);
assert_eq!(factory.make(0).unwrap(), "abc000xyz");
assert_eq!(factory.make(1).unwrap(), "abc001xyz");
assert_eq!(factory.make(123).unwrap(), "abc123xyz");
}
}

View file

@ -7,15 +7,17 @@
// spell-checker:ignore (ToDO) PREFIXaa
mod filenames;
mod platform;
use crate::filenames::FilenameFactory;
use clap::{crate_version, App, Arg, ArgMatches};
use std::convert::TryFrom;
use std::env;
use std::fs::remove_file;
use std::fs::File;
use std::io::{stdin, BufRead, BufReader, BufWriter, Read, Write};
use std::path::Path;
use std::{char, fs::remove_file};
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::parse_size::parse_size;
@ -27,7 +29,7 @@ static OPT_ADDITIONAL_SUFFIX: &str = "additional-suffix";
static OPT_FILTER: &str = "filter";
static OPT_NUMERIC_SUFFIXES: &str = "numeric-suffixes";
static OPT_SUFFIX_LENGTH: &str = "suffix-length";
static OPT_DEFAULT_SUFFIX_LENGTH: &str = "2";
static OPT_DEFAULT_SUFFIX_LENGTH: &str = "0";
static OPT_VERBOSE: &str = "verbose";
static ARG_INPUT: &str = "input";
@ -98,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
split(&settings)
split(settings)
}
pub fn uu_app<'a>() -> App<'a> {
@ -111,8 +113,7 @@ pub fn uu_app<'a>() -> App<'a> {
.short('b')
.long(OPT_BYTES)
.takes_value(true)
.default_value("2")
.help("use suffixes of length N (default 2)"),
.help("put SIZE bytes per output file"),
)
.arg(
Arg::new(OPT_LINE_BYTES)
@ -231,7 +232,6 @@ impl Strategy {
}
}
#[allow(dead_code)]
struct Settings {
prefix: String,
numeric_suffix: bool,
@ -241,7 +241,7 @@ struct Settings {
/// When supplied, a shell command to output to instead of xaa, xab …
filter: Option<String>,
strategy: Strategy,
verbose: bool, // TODO: warning: field is never read: `verbose`
verbose: bool,
}
trait Splitter {
@ -343,39 +343,7 @@ impl Splitter for ByteSplitter {
}
}
// (1, 3) -> "aab"
#[allow(clippy::many_single_char_names)]
fn str_prefix(i: usize, width: usize) -> String {
let mut c = "".to_owned();
let mut n = i;
let mut w = width;
while w > 0 {
w -= 1;
let div = 26usize.pow(w as u32);
let r = n / div;
n -= r * div;
c.push(char::from_u32((r as u32) + 97).unwrap());
}
c
}
// (1, 3) -> "001"
#[allow(clippy::many_single_char_names)]
fn num_prefix(i: usize, width: usize) -> String {
let mut c = "".to_owned();
let mut n = i;
let mut w = width;
while w > 0 {
w -= 1;
let div = 10usize.pow(w as u32);
let r = n / div;
n -= r * div;
c.push(char::from_digit(r as u32, 10).unwrap());
}
c
}
fn split(settings: &Settings) -> UResult<()> {
fn split(settings: Settings) -> UResult<()> {
let mut reader = BufReader::new(if settings.input == "-" {
Box::new(stdin()) as Box<dyn Read>
} else {
@ -395,19 +363,19 @@ fn split(settings: &Settings) -> UResult<()> {
}
};
// This object is responsible for creating the filename for each chunk.
let filename_factory = FilenameFactory::new(
settings.prefix,
settings.additional_suffix,
settings.suffix_length,
settings.numeric_suffix,
);
let mut fileno = 0;
loop {
// Get a new part file set up, and construct `writer` for it.
let mut filename = settings.prefix.clone();
filename.push_str(
if settings.numeric_suffix {
num_prefix(fileno, settings.suffix_length)
} else {
str_prefix(fileno, settings.suffix_length)
}
.as_ref(),
);
filename.push_str(settings.additional_suffix.as_ref());
let filename = filename_factory
.make(fileno)
.ok_or_else(|| USimpleError::new(1, "output file suffixes exhausted"))?;
let mut writer = platform::instantiate_current_writer(&settings.filter, filename.as_str());
let bytes_consumed = splitter
@ -429,6 +397,21 @@ fn split(settings: &Settings) -> UResult<()> {
break;
}
// TODO It is silly to have the "creating file" message here
// after the file has been already created. However, because
// of the way the main loop has been written, an extra file
// gets created and then deleted in the last iteration of the
// loop. So we need to make sure we are not in that case when
// printing this message.
//
// This is only here temporarily while we make some
// improvements to the architecture of the main loop in this
// function. In the future, it will move to a more appropriate
// place---at the point where the file is actually created.
if settings.verbose {
println!("creating file {}", filename.quote());
}
fileno += 1;
}
Ok(())

View file

@ -1,6 +1,6 @@
[package]
name = "uu_stat"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "stat ~ (uutils) display FILE status"
@ -16,8 +16,8 @@ path = "src/stat.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["entries", "libc", "fs", "fsext"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "libc", "fs", "fsext"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "stat"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_stdbuf"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "stdbuf ~ (uutils) run COMMAND with modified standard stream buffering"
@ -17,11 +17,11 @@ path = "src/stdbuf.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
tempfile = "3.1"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[build-dependencies]
libstdbuf = { version="0.0.8", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" }
libstdbuf = { version="0.0.9", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" }
[[bin]]
name = "stdbuf"

View file

@ -28,15 +28,30 @@ fn main() {
// - cargo run
// - cross run
// - cargo install --git
// - cargo publish --dry-run
let mut name = target_dir.file_name().unwrap().to_string_lossy();
while name != "target" && !name.starts_with("cargo-install") {
target_dir = target_dir.parent().unwrap();
name = target_dir.file_name().unwrap().to_string_lossy();
}
let mut libstdbuf = target_dir.to_path_buf();
libstdbuf.push(env::var("PROFILE").unwrap());
libstdbuf.push("deps");
libstdbuf.push(format!("liblibstdbuf{}", platform::DYLIB_EXT));
let mut dir = target_dir.to_path_buf();
dir.push(env::var("PROFILE").unwrap());
dir.push("deps");
let mut path = None;
fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap();
// When running cargo publish, cargo appends hashes to the filenames of the compiled artifacts.
// Therefore, it won't work to just get liblibstdbuf.so. Instead, we look for files with the
// glob pattern "liblibstdbuf*.so" (i.e. starts with liblibstdbuf and ends with the extension).
for entry in fs::read_dir(dir).unwrap().flatten() {
let name = entry.file_name();
let name = name.to_string_lossy();
if name.starts_with("liblibstdbuf") && name.ends_with(platform::DYLIB_EXT) {
path = Some(entry.path());
}
}
fs::copy(
path.expect("liblibstdbuf was not found"),
Path::new(&out_dir).join("libstdbuf.so"),
)
.unwrap();
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_stdbuf_libstdbuf"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "stdbuf/libstdbuf ~ (uutils); dynamic library required for stdbuf"
@ -19,8 +19,8 @@ crate-type = ["cdylib", "rlib"] # XXX: note: the rlib is just to prevent Cargo f
[dependencies]
cpp = "0.5"
libc = "0.2"
uucore = { version=">=0.0.10", package="uucore", path="../../../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../../../uucore_procs" }
[build-dependencies]
cpp_build = "0.4"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_sum"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "sum ~ (uutils) display checksum and block counts for input"
@ -16,8 +16,8 @@ path = "src/sum.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "sum"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_sync"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "sync ~ (uutils) synchronize cache writes to storage"
@ -17,8 +17,8 @@ path = "src/sync.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["wide"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] }
[[bin]]

View file

@ -2,7 +2,7 @@
[package]
name = "uu_tac"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "tac ~ (uutils) concatenate and display input lines in reverse order"
@ -21,8 +21,8 @@ memchr = "2"
memmap2 = "0.5"
regex = "1"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tac"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_tail"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "tail ~ (uutils) display the last lines of input"
@ -17,8 +17,8 @@ path = "src/tail.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["ringbuffer"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(windows)'.dependencies]
winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] }

View file

@ -1,6 +1,6 @@
[package]
name = "uu_tee"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "tee ~ (uutils) display input and copy to FILE"
@ -18,8 +18,8 @@ path = "src/tee.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
retain_mut = "=0.1.2" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["libc"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tee"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_test"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "test ~ (uutils) evaluate comparison and file type expressions"
@ -17,8 +17,8 @@ path = "src/test.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.2"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_timeout"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "timeout ~ (uutils) run COMMAND with a DURATION time limit"
@ -18,8 +18,8 @@ path = "src/timeout.rs"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
nix = "0.23.1"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["process", "signals"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_touch"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "touch ~ (uutils) change FILE timestamps"
@ -18,8 +18,8 @@ path = "src/touch.rs"
filetime = "0.2.1"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
time = "0.1.40"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["libc"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "touch"

View file

@ -1,6 +1,6 @@
[package]
name = "uu_tr"
version = "0.0.8"
version = "0.0.9"
authors = ["uutils developers"]
license = "MIT"
description = "tr ~ (uutils) translate characters within input and display"
@ -18,8 +18,8 @@ path = "src/tr.rs"
bit-set = "0.5.0"
fnv = "1.0.5"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
[[bin]]
name = "tr"

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