Merge branch 'main' into 2884-time-0.3

This commit is contained in:
Sylvestre Ledru
2022-05-02 18:14:14 +02:00
committed by GitHub
35 changed files with 340 additions and 53 deletions
+1 -1
View File
@@ -198,7 +198,7 @@ jobs:
do
if ! grep -Fxq ${LINE}<<<"${REF_ERROR}"
then
echo "::error ::GNU test failed: ${LINE}. ${LINE} is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?"
echo "::error ::GNU test error: ${LINE}. ${LINE} is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?"
have_new_failures="true"
fi
done
Generated
+6 -6
View File
@@ -273,9 +273,9 @@ dependencies = [
[[package]]
name = "clap_complete"
version = "3.1.2"
version = "3.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1506b87ee866f7a53a5131f7b31fba656170d797e873d0609884cfd56b8bbda8"
checksum = "1d7ca9141e27e6ebc52e3c378b0c07f3cea52db46ed1cc5861735fb697b56356"
dependencies = [
"clap 3.1.12",
]
@@ -1021,9 +1021,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.124"
version = "0.2.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50"
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
[[package]]
name = "libloading"
@@ -1623,9 +1623,9 @@ dependencies = [
[[package]]
name = "retain_mut"
version = "0.1.2"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53552c6c49e1e13f1a203ef0080ab3bbef0beb570a528993e83df057a9d9bba1"
checksum = "8c31b5c4033f8fdde8700e4657be2c497e7288f01515be52168c631e2e4d4086"
[[package]]
name = "rlimit"
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/chmod.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] }
[[bin]]
+1 -1
View File
@@ -21,7 +21,7 @@ path = "src/cp.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
filetime = "0.2"
libc = "0.2.124"
libc = "0.2.125"
quick-error = "2.0.1"
selinux = { version="0.2", optional=true }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/hostid.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[[bin]]
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/kill.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] }
[[bin]]
+1 -1
View File
@@ -15,7 +15,7 @@ edition = "2021"
path = "src/logname.rs"
[dependencies]
libc = "0.2.124"
libc = "0.2.125"
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/mkfifo.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[[bin]]
+1 -1
View File
@@ -17,7 +17,7 @@ path = "src/mknod.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "^0.2.124"
libc = "^0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] }
[[bin]]
+37 -7
View File
@@ -79,7 +79,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let template = matches.value_of(ARG_TEMPLATE).unwrap();
let tmpdir = matches.value_of(OPT_TMPDIR).unwrap_or_default();
let (template, mut tmpdir) = if matches.is_present(OPT_TMPDIR)
// Treat the template string as a path to get the directory
// containing the last component.
let path = PathBuf::from(template);
let (template, tmpdir) = if matches.is_present(OPT_TMPDIR)
&& !PathBuf::from(tmpdir).is_dir() // if a temp dir is provided, it must be an actual path
&& tmpdir.contains("XXX")
// If this is a template, it has to contain at least 3 X
@@ -97,8 +101,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let tmp = env::temp_dir();
(tmpdir, tmp)
} else if !matches.is_present(OPT_TMPDIR) {
let tmp = env::temp_dir();
(template, tmp)
// In this case, the command line was `mktemp -t XXX`, so we
// treat the argument `XXX` as though it were a filename
// regardless of whether it has path separators in it.
if matches.is_present(OPT_T) {
let tmp = env::temp_dir();
(template, tmp)
// In this case, the command line was `mktemp XXX`, so we need
// to parse out the parent directory and the filename from the
// argument `XXX`, since it may be include path separators.
} else {
let tmp = match path.parent() {
None => PathBuf::from("."),
Some(d) => PathBuf::from(d),
};
let filename = path.file_name();
let template = filename.unwrap().to_str().unwrap();
(template, tmp)
}
} else {
(template, PathBuf::from(tmpdir))
};
@@ -113,10 +133,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
return Err(MkTempError::InvalidTemplate(template.into()).into());
}
if matches.is_present(OPT_T) {
tmpdir = env::temp_dir();
}
let res = if dry_run {
dry_exec(tmpdir, prefix, rand, suffix)
} else {
@@ -272,5 +288,19 @@ fn exec(dir: &Path, prefix: &str, rand: usize, suffix: &str, make_dir: bool) ->
.map_err(|e| MkTempError::PersistError(e.file.path().to_path_buf()))?
.1
};
// Get just the last component of the path to the created
// temporary file or directory.
let filename = path.file_name();
let filename = filename.unwrap().to_str().unwrap();
// Join the directory to the path to get the path to print. We
// cannot use the path returned by the `Builder` because it gives
// the absolute path and we need to return a filename that matches
// the template given on the command-line which might be a
// relative path.
let mut path = dir.to_path_buf();
path.push(filename);
println_verbatim(path).map_err_context(|| "failed to print directory name".to_owned())
}
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/nice.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
nix = { version = "0.24.1", default-features = false }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/nohup.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
atty = "0.2"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
+1 -1
View File
@@ -15,7 +15,7 @@ edition = "2021"
path = "src/nproc.rs"
[dependencies]
libc = "0.2.124"
libc = "0.2.125"
num_cpus = "1.10"
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/pathchk.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[[bin]]
+47 -5
View File
@@ -5,7 +5,7 @@
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset
// spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset CHARCLASS
use clap::{crate_version, Arg, Command};
use regex::Regex;
@@ -31,6 +31,8 @@ const ABOUT: &str = "\
Mandatory arguments to long options are mandatory for short options too.\n\
With no FILE, or when FILE is -, read standard input. Default is '-F /'.";
const REGEX_CHARCLASS: &str = "^-]\\";
#[derive(Debug)]
enum OutFormat {
Dumb,
@@ -88,6 +90,18 @@ fn read_word_filter_file(
Ok(words)
}
/// reads contents of file as unique set of characters to be used with the break-file option
fn read_char_filter_file(
matches: &clap::ArgMatches,
option: &str,
) -> std::io::Result<HashSet<char>> {
let filename = matches.value_of(option).expect("parsing options failed!");
let mut reader = File::open(filename)?;
let mut buffer = String::new();
reader.read_to_string(&mut buffer)?;
Ok(buffer.chars().collect())
}
#[derive(Debug)]
struct WordFilter {
only_specified: bool,
@@ -113,9 +127,23 @@ impl WordFilter {
} else {
(false, HashSet::new())
};
if matches.is_present(options::BREAK_FILE) {
return Err(PtxError::NotImplemented("-b").into());
}
let break_set: Option<HashSet<char>> = if matches.is_present(options::BREAK_FILE)
&& !matches.is_present(options::WORD_REGEXP)
{
let chars =
read_char_filter_file(matches, options::BREAK_FILE).map_err_context(String::new)?;
let mut hs: HashSet<char> = if config.gnu_ext {
HashSet::new() // really only chars found in file
} else {
// GNU off means at least these are considered
[' ', '\t', '\n'].iter().cloned().collect()
};
hs.extend(chars);
Some(hs)
} else {
// if -W takes precedence or default
None
};
// Ignore empty string regex from cmd-line-args
let arg_reg: Option<String> = if matches.is_present(options::WORD_REGEXP) {
match matches.value_of(options::WORD_REGEXP) {
@@ -134,7 +162,21 @@ impl WordFilter {
let reg = match arg_reg {
Some(arg_reg) => arg_reg,
None => {
if config.gnu_ext {
if break_set.is_some() {
format!(
"[^{}]+",
break_set
.unwrap()
.into_iter()
.map(|c| if REGEX_CHARCLASS.contains(c) {
format!("\\{}", c)
} else {
c.to_string()
})
.collect::<Vec<String>>()
.join("")
)
} else if config.gnu_ext {
"\\w+".to_owned()
} else {
"[^ \t\n]+".to_owned()
+1 -1
View File
@@ -17,7 +17,7 @@ path = "src/rmdir.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
libc = "0.2.124"
libc = "0.2.125"
[[bin]]
name = "rmdir"
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/sync.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] }
winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] }
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/tail.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer", "lines"] }
[target.'cfg(windows)'.dependencies]
+2 -2
View File
@@ -16,8 +16,8 @@ path = "src/tee.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
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
libc = "0.2.125"
retain_mut = "=0.1.7" # 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.11", package="uucore", path="../../uucore", features=["libc"] }
[[bin]]
+1 -1
View File
@@ -16,7 +16,7 @@ path = "src/test.rs"
[dependencies]
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
libc = "0.2.124"
libc = "0.2.125"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
[target.'cfg(target_os = "redox")'.dependencies]

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