Skip to content

Commit

Permalink
Merge branch 'main' into truncate-no-such-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre authored Jan 29, 2022
2 parents c780c96 + cbc7da3 commit 57ee6b5
Show file tree
Hide file tree
Showing 114 changed files with 424 additions and 246 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ clap_complete = "3.0"
lazy_static = { version="1.3" }
textwrap = { version="0.14", features=["terminal_size"] }
uucore = { version=">=0.0.11", package="uucore", path="src/uucore" }
selinux = { version="0.2.3", optional = true }
selinux = { version="0.2", optional = true }
# * uutils
uu_test = { optional=true, version="0.0.12", package="uu_test", path="src/uu/test" }
#
Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@
<!-- spell-checker:ignore markdownlint ; (options) DESTDIR RUNTEST UTILNAME -->

uutils is an attempt at writing universal (as in cross-platform) CLI
utilities in [Rust](http://www.rust-lang.org). This repository is intended to
aggregate GNU coreutils rewrites.
utilities in [Rust](http://www.rust-lang.org).

## Why?

Many GNU, Linux and other utilities are useful, and obviously
[some](http://gnuwin32.sourceforge.net) [effort](http://unxutils.sourceforge.net)
has been spent in the past to port them to Windows. However, those projects
are written in platform-specific C, a language considered unsafe compared to Rust, and
have other issues.
uutils aims to work on as many platforms as possible, to be able to use the
same utils on Linux, Mac, Windows and other platforms. This ensures, for
example, that scripts can be easily transferred between platforms. Rust was
chosen not only because it is fast and safe, but is also excellent for
writing cross-platform code.

Rust provides a good, platform-agnostic way of writing systems utilities that are easy
to compile anywhere, and this is as good a way as any to try and learn it.
## Documentation
uutils has both user and developer documentation available:

- [User Manual](https://uutils.github.io/coreutils-docs/user/)
- [Developer Documentation](https://uutils.github.io/coreutils-docs/dev/)

Both can also be generated locally, the instructions for that can be found in the
[coreutils docs](https://github.com/uutils/coreutils-docs) repository.

<!-- ANCHOR: installation (this mark is needed for mdbook) -->
## Requirements

* Rust (`cargo`, `rustc`)
* GNU Make (required to build documentation)
* [Sphinx](http://www.sphinx-doc.org/) (for documentation)
* gzip (for installing documentation)
* GNU Make (optional)

### Rust Version

Expand All @@ -44,7 +47,7 @@ The current oldest supported version of the Rust compiler is `1.54`.

On both Windows and Redox, only the nightly version is tested currently.

## Build Instructions
## Building

There are currently two methods to build the uutils binaries: either Cargo
or GNU Make.
Expand Down Expand Up @@ -123,7 +126,7 @@ To build only a few of the available utilities:
$ make UTILS='UTILITY_1 UTILITY_2'
```

## Installation Instructions
## Installation

### Cargo

Expand Down Expand Up @@ -213,7 +216,7 @@ run:
cargo run completion ls bash > /usr/local/share/bash-completion/completions/ls
```

## Un-installation Instructions
## Un-installation

Un-installation differs depending on how you have installed uutils. If you used
Cargo to install, use Cargo to uninstall. If you used GNU Make to install, use
Expand Down Expand Up @@ -255,7 +258,7 @@ $ make PREFIX=/my/path uninstall
```
<!-- ANCHOR_END: installation (this mark is needed for mdbook) -->

## Test Instructions
## Testing

Testing can be done using either Cargo or `make`.

Expand Down Expand Up @@ -321,7 +324,7 @@ To include tests for unimplemented behavior:
$ make UTILS='UTILITY_1 UTILITY_2' SPEC=y test
```

## Run Busybox Tests
### Run Busybox Tests

This testing functionality is only available on *nix operating systems and
requires `make`.
Expand All @@ -344,7 +347,7 @@ To pass an argument like "-v" to the busybox test runtime
$ make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest
```

## Comparing with GNU
### Comparing with GNU

![Evolution over time](https://github.com/uutils/coreutils-tracking/blob/main/gnu-results.png?raw=true)

Expand All @@ -359,7 +362,7 @@ $ bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example

Note that it relies on individual utilities (not the multicall binary).

## Contribute
## Contributing

To contribute to uutils, please see [CONTRIBUTING](CONTRIBUTING.md).

Expand Down
3 changes: 2 additions & 1 deletion src/uu/arch/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use platform_info::*;

use clap::{crate_version, App};
use clap::{crate_version, App, AppSettings};
use uucore::error::{FromIo, UResult};

static ABOUT: &str = "Display machine architecture";
Expand All @@ -28,4 +28,5 @@ pub fn uu_app<'a>() -> App<'a> {
.version(crate_version!())
.about(ABOUT)
.after_help(SUMMARY)
.setting(AppSettings::InferLongArgs)
}
3 changes: 2 additions & 1 deletion src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::fs::File;
use std::io::{BufReader, Stdin};
use std::path::Path;

use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};

pub static BASE_CMD_PARSE_ERROR: i32 = 1;

Expand Down Expand Up @@ -97,6 +97,7 @@ pub fn base_app(about: &str) -> App {
App::new(uucore::util_name())
.version(crate_version!())
.about(about)
.setting(AppSettings::InferLongArgs)
// Format arguments.
.arg(
Arg::new(options::DECODE)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// spell-checker:ignore (ToDO) fullname

use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
use std::path::{is_separator, PathBuf};
use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError};
Expand Down Expand Up @@ -97,6 +97,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::MULTIPLE)
.short('a')
Expand Down
3 changes: 0 additions & 3 deletions src/uu/basenc/src/basenc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const ENCODINGS: &[(&str, Format)] = &[
("base2lsbf", Format::Base2Lsbf),
("base2msbf", Format::Base2Msbf),
("z85", Format::Z85),
// common abbreviations. TODO: once we have clap 3.0 we can use `AppSettings::InferLongArgs` to get all abbreviations automatically
("base2l", Format::Base2Lsbf),
("base2m", Format::Base2Msbf),
];

fn usage() -> String {
Expand Down
3 changes: 2 additions & 1 deletion src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
extern crate unix_socket;

// last synced with: cat (GNU coreutils) 8.13
use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
use std::fs::{metadata, File};
use std::io::{self, Read, Write};
use thiserror::Error;
Expand Down Expand Up @@ -245,6 +245,7 @@ pub fn uu_app<'a>() -> App<'a> {
.version(crate_version!())
.override_usage(SYNTAX)
.about(SUMMARY)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::FILE)
.hide(true)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/chcon/src/chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::{display::Quotable, show_error, show_warning};

use clap::{App, Arg};
use clap::{App, AppSettings, Arg};
use selinux::{OpaqueSecurityContext, SecurityContext};

use std::borrow::Cow;
Expand Down Expand Up @@ -164,6 +164,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(VERSION)
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::dereference::DEREFERENCE)
.long(options::dereference::DEREFERENCE)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/chgrp/src/chgrp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub use uucore::entries;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::perms::{chown_base, options, IfFrom};

use clap::{App, Arg, ArgMatches};
use clap::{App, AppSettings, Arg, ArgMatches};

use std::fs;
use std::os::unix::fs::MetadataExt;
Expand Down Expand Up @@ -68,6 +68,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(VERSION)
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::verbosity::CHANGES)
.short('c')
Expand Down
3 changes: 2 additions & 1 deletion src/uu/chmod/src/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// spell-checker:ignore (ToDO) Chmoder cmode fmode fperm fref ugoa RFILE RFILE's

use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
use std::fs;
use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::Path;
Expand Down Expand Up @@ -125,6 +125,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::CHANGES)
.long(options::CHANGES)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/chown/src/chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use uucore::perms::{chown_base, options, IfFrom};

use uucore::error::{FromIo, UResult, USimpleError};

use clap::{crate_version, App, Arg, ArgMatches};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches};

use std::fs;
use std::os::unix::fs::MetadataExt;
Expand Down Expand Up @@ -71,6 +71,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::verbosity::CHANGES)
.short('c')
Expand Down
3 changes: 2 additions & 1 deletion src/uu/chroot/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
mod error;

use crate::error::ChrootError;
use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
use std::ffi::CString;
use std::io::Error;
use std::path::Path;
Expand Down Expand Up @@ -96,6 +96,7 @@ pub fn uu_app<'a>() -> App<'a> {
.version(crate_version!())
.about(ABOUT)
.override_usage(SYNTAX)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::NEWROOT)
.hide(true)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// file that was distributed with this source code.

// spell-checker:ignore (ToDO) fname
use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
use std::fs::File;
use std::io::{self, stdin, BufReader, Read};
use std::path::Path;
Expand Down Expand Up @@ -146,6 +146,7 @@ pub fn uu_app<'a>() -> App<'a> {
.version(crate_version!())
.about(SUMMARY)
.override_usage(SYNTAX)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::FILE)
.hide(true)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/comm/src/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use uucore::error::FromIo;
use uucore::error::UResult;
use uucore::InvalidEncodingHandling;

use clap::{crate_version, App, Arg, ArgMatches};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches};

static ABOUT: &str = "compare two sorted files line by line";
static LONG_HELP: &str = "";
Expand Down Expand Up @@ -152,6 +152,7 @@ pub fn uu_app<'a>() -> App<'a> {
.version(crate_version!())
.about(ABOUT)
.after_help(LONG_HELP)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::COLUMN_1)
.short('1')
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] }
filetime = "0.2"
libc = "0.2.85"
quick-error = "1.2.3"
selinux = { version="0.2.3", optional=true }
selinux = { version="0.2", optional=true }
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"
Expand Down
3 changes: 2 additions & 1 deletion src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use winapi::um::fileapi::GetFileInformationByHandle;

use std::borrow::Cow;

use clap::{crate_version, App, Arg, ArgMatches};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches};
use filetime::FileTime;
use quick_error::ResultExt;
use std::collections::HashSet;
Expand Down Expand Up @@ -300,6 +300,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
.arg(Arg::new(options::TARGET_DIRECTORY)
.short('t')
.conflicts_with(options::NO_TARGET_DIRECTORY)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
io::{BufRead, BufWriter, Write},
};

use clap::{crate_version, App, Arg, ArgMatches};
use clap::{crate_version, App, AppSettings, Arg, ArgMatches};
use regex::Regex;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult};
Expand Down Expand Up @@ -757,6 +757,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::SUFFIX_FORMAT)
.short('b')
Expand Down
3 changes: 2 additions & 1 deletion src/uu/cut/src/cut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
extern crate uucore;

use bstr::io::BufReadExt;
use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
use std::fs::File;
use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write};
use std::path::Path;
Expand Down Expand Up @@ -539,6 +539,7 @@ pub fn uu_app<'a>() -> App<'a> {
.override_usage(SYNTAX)
.about(SUMMARY)
.after_help(LONG_HELP)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(options::BYTES)
.short('b')
Expand Down
3 changes: 2 additions & 1 deletion src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use chrono::{DateTime, FixedOffset, Local, Offset, Utc};
#[cfg(windows)]
use chrono::{Datelike, Timelike};
use clap::{crate_version, App, Arg};
use clap::{crate_version, App, AppSettings, Arg};
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
use libc::{clock_settime, timespec, CLOCK_REALTIME};
use std::fs::File;
Expand Down Expand Up @@ -261,6 +261,7 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
.arg(
Arg::new(OPT_DATE)
.short('d')
Expand Down
Loading

0 comments on commit 57ee6b5

Please sign in to comment.