Giter VIP home page Giter VIP logo

coreutils's Introduction

uutils logo

uutils coreutils

Crates.io Discord License dependency status

CodeCov MSRV


uutils coreutils is a cross-platform reimplementation of the GNU coreutils in Rust. While all programs have been implemented, some options might be missing or different behavior might be experienced.

To install it:

cargo install coreutils
~/.cargo/bin/coreutils

Goals

uutils aims to be a drop-in replacement for the GNU utils. Differences with GNU are treated as bugs.

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.

Documentation

uutils has both user and developer documentation available:

Both can also be generated locally, the instructions for that can be found in the coreutils docs repository.

Requirements

  • Rust (cargo, rustc)
  • GNU Make (optional)

Rust Version

uutils follows Rust's release channels and is tested against stable, beta and nightly. The current Minimum Supported Rust Version (MSRV) is 1.70.0.

Building

There are currently two methods to build the uutils binaries: either Cargo or GNU Make.

Building the full package, including all documentation, requires both Cargo and Gnu Make on a Unix platform.

For either method, we first need to fetch the repository:

git clone https://github.com/uutils/coreutils
cd coreutils

Cargo

Building uutils using Cargo is easy because the process is the same as for every other Rust program:

cargo build --release

This command builds the most portable common core set of uutils into a multicall (BusyBox-type) binary, named 'coreutils', on most Rust-supported platforms.

Additional platform-specific uutils are often available. Building these expanded sets of uutils for a platform (on that platform) is as simple as specifying it as a feature:

cargo build --release --features macos
# or ...
cargo build --release --features windows
# or ...
cargo build --release --features unix

If you don't want to build every utility available on your platform into the final binary, you can also specify which ones you want to build manually. For example:

cargo build --features "base32 cat echo rm" --no-default-features

If you don't want to build the multicall binary and would prefer to build the utilities as individual binaries, that is also possible. Each utility is contained in its own package within the main repository, named "uu_UTILNAME". To build individual utilities, use cargo to build just the specific packages (using the --package [aka -p] option). For example:

cargo build -p uu_base32 -p uu_cat -p uu_echo -p uu_rm

GNU Make

Building using make is a simple process as well.

To simply build all available utilities:

make

In release mode:

make PROFILE=release

To build all but a few of the available utilities:

make SKIP_UTILS='UTILITY_1 UTILITY_2'

To build only a few of the available utilities:

make UTILS='UTILITY_1 UTILITY_2'

Installation

Install with Cargo

Likewise, installing can simply be done using:

cargo install --path . --locked

This command will install uutils into Cargo's bin folder (e.g. $HOME/.cargo/bin).

This does not install files necessary for shell completion or manpages. For manpages or shell completion to work, use GNU Make or see Manually install shell completions/Manually install manpages.

Install with GNU Make

To install all available utilities:

make install

To install using sudo switch -E must be used:

sudo -E make install

To install all but a few of the available utilities:

make SKIP_UTILS='UTILITY_1 UTILITY_2' install

To install only a few of the available utilities:

make UTILS='UTILITY_1 UTILITY_2' install

To install every program with a prefix (e.g. uu-echo uu-cat):

make PROG_PREFIX=PREFIX_GOES_HERE install

To install the multicall binary:

make MULTICALL=y install

Set install parent directory (default value is /usr/local):

# DESTDIR is also supported
make PREFIX=/my/path install

Installing with make installs shell completions for all installed utilities for bash, fish and zsh. Completions for elvish and powershell can also be generated; See Manually install shell completions.

Manually install shell completions

The coreutils binary can generate completions for the bash, elvish, fish, powershell and zsh shells. It prints the result to stdout.

The syntax is:

cargo run completion <utility> <shell>

So, to install completions for ls on bash to /usr/local/share/bash-completion/completions/ls, run:

cargo run completion ls bash > /usr/local/share/bash-completion/completions/ls

Manually install manpages

To generate manpages, the syntax is:

cargo run manpage <utility>

So, to install the manpage for ls to /usr/local/share/man/man1/ls.1 run:

cargo run manpage ls > /usr/local/share/man/man1/ls.1

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 Make to uninstall.

Uninstall with Cargo

To uninstall uutils:

cargo uninstall uutils

Uninstall with GNU Make

To uninstall all utilities:

make uninstall

To uninstall every program with a set prefix:

make PROG_PREFIX=PREFIX_GOES_HERE uninstall

To uninstall the multicall binary:

make MULTICALL=y uninstall

To uninstall from a custom parent directory:

# DESTDIR is also supported
make PREFIX=/my/path uninstall

GNU test suite compatibility

Below is the evolution of how many GNU tests uutils passes. A more detailed breakdown of the GNU test results of the main branch can be found in the user manual.

See https://github.com/orgs/uutils/projects/1 for the main meta bugs (many are missing).

Evolution over time

Contributing

To contribute to uutils, please see CONTRIBUTING.

License

uutils is licensed under the MIT License - see the LICENSE file for details

GNU Coreutils is licensed under the GPL 3.0 or later.

coreutils's People

Contributors

arcterus avatar backwaterred avatar benwiederhake avatar blyxxyz avatar cakebaker avatar cnd avatar dependabot-support avatar dependabot[bot] avatar ebfe avatar hbina avatar jaggededgedjustice avatar jbcrail avatar jfinkels avatar jhscheer avatar joining7943 avatar kimono-koans avatar knight42 avatar lcheylus avatar mideb avatar nathanross avatar nbraud avatar niyaznigmatullin avatar renovate[bot] avatar rivy avatar seldaek avatar shinhs0506 avatar sylvestre avatar tertsdiepraam avatar thomasqueirozb avatar zhitkoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coreutils's Issues

hostname

Hey guys, I'd like to implement hostname. It that ok ?

thanks :)

Add a contribution guide

I think this is an excellent project that many people can contribute to, since it can be developed in parallel by its nature.

To avoid the possibility of multiple people working on the same util, it'd be nice to have a way for people to "claim" an item.

show_error, crash macros rethink

Hey guys,

While I was trying to extract code from id.rs to use it in groups.rs I stumble upon a problem with the macros that we currently use. I've exposed this problem in the most recent meetup and also in the IRC, and the conclusion was basically the same.

The problem is the following.

groups.rs will include c_types.rs
c_types.rs will use crash! that is defined in util.rs which is being included by groups.rs
When I try to compile the program, I get this error:

sh -c 'rustc --opt-level=3 -o build/id id/id.rs'
common/util.rs:16:62: 16:66 error: unresolved name `NAME`. Did you mean `free`?
common/util.rs:16         safe_write!(&mut ::std::io::stderr(), "{}: error: ", NAME);
                                                                               ^~~~
note: in expansion of format_args!
<std macros>:4:9: 5:6 note: expansion site
<std macros>:1:1: 1:1 note: in expansion of write!
common/util.rs:32:15: 32:40 note: expansion site
common/util.rs:30:1: 37:2 note: in expansion of safe_write!
common/util.rs:16:9: 16:68 note: expansion site
common/util.rs:13:1: 19:2 note: in expansion of show_error!
common/util.rs:24:9: 24:44 note: expansion site
common/util.rs:22:1: 27:2 note: in expansion of crash!
common/c_types.rs:48:17: 48:59 note: expansion site
common/util.rs:16:62: 16:66 error: unresolved name `NAME`. Did you mean `free`?
common/util.rs:16         safe_write!(&mut ::std::io::stderr(), "{}: error: ", NAME);
                                                                               ^~~~
  1. This macro shouldn't work at all because of macros hygiene. It works however...
  2. Solution proposed is to pass the name of the program as an argument, not as a constant.

What is target rust version?

Suggestion: add answer to readme.

If target rust version is not current then create branch for current version.

I ask because for example there is no from_utf8_slice_opt anymore

Make cat fails

I'm using rust -v 0.9-pre (aa4455e...)

When I do make on the main directory, cat fails with this.

sh -c 'rustc --opt-level=3 -o build/cat cat/cat.rs'
cat/cat.rs:185:32: 185:53 error: unresolved name `std::path::Path::init`.
cat/cat.rs:185     match result(|| File::open(&std::path::Path::init(path.as_slice()))) {
                                               ^~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /Users/alan/lang/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /Users/alan/lang/rust/src/librustc/lib.rs:390
make: *** [build/cat] Error 101

Is it me or the program ?

Implement ls

I'd like to work on this. (I already started in fact).
I saw there was already #34 but no answer since 3 months so I'd like to take the liberty to do it if there is no problem with that.

Logo image

What about an logo image?
What do you want to see as logo image?

What about the ring from Rust logo and some instruments in the middle?

Separate linux-only utils in Makefile

Some of utils are currently linux only. whoami , hostname ... We should separate them from crossplatform list somehow.

And ideally make the make to automatically detect to use both lists or crossplatform only

Implement uptime

I already implemented a version for linux only. First I use strftime to format time but removed it because of simplicity and less dependencies.
It uses /proc/uptime for uptime, code from users for the number of users and getloadavg() for load average. Both /proc/uptime and getloadavg are unix only (linux only?) so in the meantime I added uptime to UNIX_PROGS.
Based roughly on the code from C coreutils.

binary size is scary

I know its a rust issue, but looking at about 3MB for each binary, versus around 100KB for coreutils binaries on my system (ubuntu 14.04), I wonder if there is anything that can be done to cut it down.

Implement logname

I'd like to work on this.

logname is very similar to whoami. Do i need to use a common folder, like stated in #103?

dev vs. individual branches

After thinking about this, I'm pretty sure that rather than a dev branch, we should have individual branches for big projects that are not yet "complete" (e.g. cp). What does everyone else think?

Standardize the interfaces of the various utilities

For example, some utilities display errors like utilname: error msg, while others do it like error: error msg, while yet more do error msg.

IMHO, they should all be utilname: error: error msg or something of the sort. That way, people will know which utility failed if multiple are executed in a shell script and for normal usage people will be able to tell that there was an error.

Implement rmdir

I'll do this too, seeing as it's so closely related to rm.

whoami: Build failure on Windows

note: build\whoami.o:fake:(.text+0x687): undefined reference to `geteuid'
build\whoami.o:fake:(.text+0x68f): undefined reference to `getpwuid'

Code reuse in groups & id

The id program has options that will do the same as groups program.

Also, the id program has a bunch of structs that could be reused not only by groups, but other programs.

Before proceeding with the groups program, I want to ask for some help to decide what to do.

  1. We can make public structs and put them in their own file. This way whoami , id and potentially groups could those structs.
  2. Make some of the id program functions public so that groups can reuse them with no effort.

Thanks.

`link` attribute obsolete

After commit rust-lang/rust@e09a8e8, the link attribute is obsolete. It's an easy fix, but the author parameter is lost. I don't know if there's another attribute to use for that. In any case it doesn't seem significant.

Define standards

What exactly are we aiming for in these implementations: are we aiming to replicate the quirks of the GNU implementations exactly? Or trying to be POSIXly correct? Or just doing our best for now and worrying about the details later?

My 2p: the GNU quirks aren't all good, e.g. GNU uniq -i thinks 'Γ' and 'γ' are distinct.

Implement echo

I will be working on echo. Just wanted to make sure no one else is working on it :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.