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

Merge branch 'main' into hotfix-mktemp

This commit is contained in:
Zaú Júlio 2023-03-03 14:22:07 -03:00 committed by GitHub
commit 65b1be9456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 51 deletions

View file

@ -86,7 +86,7 @@ jobs:
run: |
## Install dependencies
sudo apt-get update
sudo apt-get install autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl
sudo apt-get install -y autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev
- name: Add various locales
shell: bash
run: |
@ -316,8 +316,8 @@ jobs:
- name: Install dependencies
run: |
## Install dependencies
sudo apt update
sudo apt install autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl -y
sudo apt-get update
sudo apt-get install -y autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev
- name: Add various locales
run: |
## Add various locales

View file

@ -0,0 +1,9 @@
# basename
```
basename NAME [SUFFIX]
basename OPTION... NAME...
```
Print NAME with any leading directory components removed
If specified, also remove a trailing SUFFIX

View file

@ -11,13 +11,11 @@ use clap::{crate_version, Arg, ArgAction, Command};
use std::path::{is_separator, PathBuf};
use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError};
use uucore::format_usage;
use uucore::{format_usage, help_about, help_usage};
static ABOUT: &str = r#"Print NAME with any leading directory components removed
If specified, also remove a trailing SUFFIX"#;
static ABOUT: &str = help_about!("basename.md");
const USAGE: &str = "{} NAME [SUFFIX]
{} OPTION... NAME...";
const USAGE: &str = help_usage!("basename.md");
pub mod options {
pub static MULTIPLE: &str = "multiple";

11
src/uu/chcon/chcon.md Normal file
View file

@ -0,0 +1,11 @@
<!-- spell-checker:ignore (vars) RFILE -->
# chcon
```
chcon [OPTION]... CONTEXT FILE...
chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
chcon [OPTION]... --reference=RFILE FILE...
```
Change the SELinux security context of each FILE to CONTEXT.
With --reference, change the security context of each FILE to that of RFILE.

View file

@ -1,11 +1,9 @@
// spell-checker:ignore (vars) RFILE
#![allow(clippy::upper_case_acronyms)]
use clap::builder::ValueParser;
use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::format_usage;
use uucore::{display::Quotable, show_error, show_warning};
use uucore::{display::Quotable, format_usage, help_about, help_usage, show_error, show_warning};
use clap::{Arg, ArgAction, Command};
use selinux::{OpaqueSecurityContext, SecurityContext};
@ -21,13 +19,9 @@ mod fts;
use errors::*;
static VERSION: &str = env!("CARGO_PKG_VERSION");
static ABOUT: &str = "Change the SELinux security context of each FILE to CONTEXT. \n\
With --reference, change the security context of each FILE to that of RFILE.";
const USAGE: &str = "\
{} [OPTION]... CONTEXT FILE... \n \
{} [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE... \n \
{} [OPTION]... --reference=RFILE FILE...";
const VERSION: &str = env!("CARGO_PKG_VERSION");
const ABOUT: &str = help_about!("chcon.md");
const USAGE: &str = help_usage!("chcon.md");
pub mod options {
pub static HELP: &str = "help";

9
src/uu/chown/chown.md Normal file
View file

@ -0,0 +1,9 @@
<!-- spell-checker:ignore RFILE -->
# chown
```
chown [OPTION]... [OWNER][:[GROUP]] FILE...
chown [OPTION]... --reference=RFILE FILE...
```
Change file owner and group

View file

@ -9,8 +9,8 @@
use uucore::display::Quotable;
pub use uucore::entries::{self, Group, Locate, Passwd};
use uucore::format_usage;
use uucore::perms::{chown_base, options, IfFrom};
use uucore::{format_usage, help_about, help_usage};
use uucore::error::{FromIo, UResult, USimpleError};
@ -19,11 +19,9 @@ use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
use std::fs;
use std::os::unix::fs::MetadataExt;
static ABOUT: &str = "Change file owner and group";
static ABOUT: &str = help_about!("chown.md");
const USAGE: &str = "\
{} [OPTION]... [OWNER][:[GROUP]] FILE...
{} [OPTION]... --reference=RFILE FILE...";
const USAGE: &str = help_usage!("chown.md");
fn parse_gid_uid_and_filter(matches: &ArgMatches) -> UResult<(Option<u32>, Option<u32>, IfFrom)> {
let filter = if let Some(spec) = matches.get_one::<String>(options::FROM) {

View file

@ -14,8 +14,8 @@ use std::os::unix::fs::FileTypeExt;
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::format_usage;
use uucore::parse_size::{parse_size, ParseSizeError};
use uucore::{format_usage, help_about, help_section, help_usage};
#[derive(Debug, Eq, PartialEq)]
enum TruncateMode {
@ -73,25 +73,9 @@ impl TruncateMode {
}
}
const ABOUT: &str = "Shrink or extend the size of each file to the specified size.";
const USAGE: &str = "{} [OPTION]... [FILE]...";
const LONG_USAGE: &str = "\
SIZE is an integer with an optional prefix and optional unit.
The available units (K, M, G, T, P, E, Z, and Y) use the following format:
'KB' => 1000 (kilobytes)
'K' => 1024 (kibibytes)
'MB' => 1000*1000 (megabytes)
'M' => 1024*1024 (mebibytes)
'GB' => 1000*1000*1000 (gigabytes)
'G' => 1024*1024*1024 (gibibytes)
SIZE may also be prefixed by one of the following to adjust the size of each
file based on its current size:
'+' => extend by
'-' => reduce by
'<' => at most
'>' => at least
'/' => round down to multiple of
'%' => round up to multiple of";
const ABOUT: &str = help_about!("truncate.md");
const AFTER_HELP: &str = help_section!("after help", "truncate.md");
const USAGE: &str = help_usage!("truncate.md");
pub mod options {
pub static IO_BLOCKS: &str = "io-blocks";
@ -104,7 +88,7 @@ pub mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app()
.after_help(LONG_USAGE)
.after_help(AFTER_HELP)
.try_get_matches_from(args)
.map_err(|e| {
e.print().expect("Error writing clap::Error");

View file

@ -0,0 +1,25 @@
# truncate
truncate [OPTION]... [FILE]...
```
Shrink or extend the size of each file to the specified size.
## After help
SIZE is an integer with an optional prefix and optional unit.
The available units (K, M, G, T, P, E, Z, and Y) use the following format:
'KB' => 1000 (kilobytes)
'K' => 1024 (kibibytes)
'MB' => 1000*1000 (megabytes)
'M' => 1024*1024 (mebibytes)
'GB' => 1000*1000*1000 (gigabytes)
'G' => 1024*1024*1024 (gibibytes)
SIZE may also be prefixed by one of the following to adjust the size of each
file based on its current size:
'+' => extend by
'-' => reduce by
'<' => at most
'>' => at least
'/' => round down to multiple of
'%' => round up to multiple of

View file

@ -15,7 +15,7 @@ use count_fast::{count_bytes_chars_and_lines_fast, count_bytes_fast};
use countable::WordCountable;
use unicode_width::UnicodeWidthChar;
use utf8::{BufReadDecoder, BufReadDecoderError};
use uucore::{format_usage, show};
use uucore::{format_usage, help_about, help_usage, show};
use word_count::{TitledWordCount, WordCount};
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
@ -98,9 +98,8 @@ impl Settings {
}
}
static ABOUT: &str = "Display newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -, read standard input.";
const USAGE: &str = "{} [OPTION]... [FILE]...";
const ABOUT: &str = help_about!("wc.md");
const USAGE: &str = help_usage!("wc.md");
pub mod options {
pub static BYTES: &str = "bytes";

7
src/uu/wc/wc.md Normal file
View file

@ -0,0 +1,7 @@
# wc
wc [OPTION]... [FILE]...
```
Display newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -, read standard input.

View file

@ -391,7 +391,12 @@ fn test_du_h_flag_empty_file() {
fn test_du_time() {
let ts = TestScenario::new(util_name!());
// du --time formats the timestamp according to the local timezone. We set the TZ
// environment variable to UTC in the commands below to ensure consistent outputs
// and test results regardless of the timezone of the machine this test runs in.
ts.ccmd("touch")
.env("TZ", "UTC")
.arg("-a")
.arg("-t")
.arg("201505150000")
@ -399,19 +404,35 @@ fn test_du_time() {
.succeeds();
ts.ccmd("touch")
.env("TZ", "UTC")
.arg("-m")
.arg("-t")
.arg("201606160000")
.arg("date_test")
.succeeds();
let result = ts.ucmd().arg("--time").arg("date_test").succeeds();
let result = ts
.ucmd()
.env("TZ", "UTC")
.arg("--time")
.arg("date_test")
.succeeds();
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
let result = ts.ucmd().arg("--time=atime").arg("date_test").succeeds();
let result = ts
.ucmd()
.env("TZ", "UTC")
.arg("--time=atime")
.arg("date_test")
.succeeds();
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
let result = ts.ucmd().arg("--time=ctime").arg("date_test").succeeds();
let result = ts
.ucmd()
.env("TZ", "UTC")
.arg("--time=ctime")
.arg("date_test")
.succeeds();
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
if birth_supported() {