Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/coreutils/artifacts.js b/coreutils/artifacts.js new file mode 100644 index 000000000..2dbfc7072 --- /dev/null +++ b/coreutils/artifacts.js @@ -0,0 +1,245 @@ +/* Code modified from the blender website + * https://www.blender.org/wp-content/themes/bthree/assets/js/get_os.js?x82196 + */ + +let options = { + windows64: "x86_64-pc-windows", + windows32: "i686-pc-windows", + windowsArm: "aarch64-pc-windows", + + mac64: "x86_64-apple", + mac32: "i686-apple", + macSilicon: "aarch64-apple", + + linux64: "x86_64-unknown-linux", + linux32: "i686-unknown-linux", + linuxArm: "aarch64-unknown-linux", + + // ios: "ios", + // android: "linux-android", + // freebsd: "freebsd", +}; + +function isAppleSilicon() { + try { + var glcontext = document.createElement("canvas").getContext("webgl"); + var debugrenderer = glcontext + ? glcontext.getExtension("WEBGL_debug_renderer_info") + : null; + var renderername = + (debugrenderer && + glcontext.getParameter(debugrenderer.UNMASKED_RENDERER_WEBGL)) || + ""; + if (renderername.match(/Apple M/) || renderername.match(/Apple GPU/)) { + return true; + } + + return false; + } catch (e) {} +} + +function getOS() { + var OS = options.windows64.default; + var userAgent = navigator.userAgent; + var platform = navigator.platform; + + if (navigator.appVersion.includes("Win")) { + if ( + !userAgent.includes("Windows NT 5.0") && + !userAgent.includes("Windows NT 5.1") && + (userAgent.indexOf("Win64") > -1 || + platform == "Win64" || + userAgent.indexOf("x86_64") > -1 || + userAgent.indexOf("x86_64") > -1 || + userAgent.indexOf("amd64") > -1 || + userAgent.indexOf("AMD64") > -1 || + userAgent.indexOf("WOW64") > -1) + ) { + OS = options.windows64; + } else { + if ( + window.external && + window.external.getHostEnvironmentValue && + window.external + .getHostEnvironmentValue("os-architecture") + .includes("ARM64") + ) { + OS = options.windowsArm; + } else { + try { + var canvas = document.createElement("canvas"); + var gl = canvas.getContext("webgl"); + + var debugInfo = gl.getExtension("WEBGL_debug_renderer_info"); + var renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL); + if (renderer.includes("Qualcomm")) OS = options.windowsArm; + } catch (e) {} + } + } + } + + //MacOS, MacOS X, macOS + if (navigator.appVersion.includes("Mac")) { + if ( + navigator.userAgent.includes("OS X 10.5") || + navigator.userAgent.includes("OS X 10.6") + ) { + OS = options.mac32; + } else { + OS = options.mac64; + + const isSilicon = isAppleSilicon(); + if (isSilicon) { + OS = options.macSilicon; + } + } + } + + // linux + if (platform.includes("Linux")) { + OS = options.linux64; + // FIXME: Can we find out whether linux 32-bit or ARM are used? + } + + // if ( + // userAgent.includes("iPad") || + // userAgent.includes("iPhone") || + // userAgent.includes("iPod") + // ) { + // OS = options.ios; + // } + // if (platform.toLocaleLowerCase().includes("freebsd")) { + // OS = options.freebsd; + // } + + return OS; +} + +let os = getOS(); +window.os = os; + +// Unhide and hydrate selector with events +const archSelect = document.querySelector(".arch-select"); +if (archSelect) { + archSelect.classList.remove("hidden"); + const selector = document.querySelector("#install-arch-select"); + if (selector) { + selector.addEventListener("change", onArchChange); + } +} + +// Hydrate tab buttons with events +Array.from(document.querySelectorAll(".install-tab[data-id]")).forEach((tab) => { + tab.addEventListener("click", onTabClick); +}); + +function onArchChange(evt) { + // Get target + const target = evt.currentTarget.value; + // Find corresponding installer lists + const newContentEl = document.querySelector(`.arch[data-arch=${target}]`); + const oldContentEl = document.querySelector(`.arch[data-arch]:not(.hidden)`); + // Hide old content element (if applicable) + if (oldContentEl) { + oldContentEl.classList.add("hidden"); + } + // Show new content element + newContentEl.classList.remove("hidden"); + // Show the first tab's content if nothing was selected before + if (newContentEl.querySelectorAll(".install-tab.selected").length === 0) { + const firstContentChild = newContentEl.querySelector(".install-content:first-of-type"); + const firstTabChild = newContentEl.querySelector(".install-tab:first-of-type"); + firstContentChild.classList.remove("hidden"); + if (firstTabChild) { + firstTabChild.classList.add("selected"); + } + } + // Hide "no OS detected" message + const noDetectEl = document.querySelector(".no-autodetect"); + noDetectEl.classList.add("hidden"); + // Hide Mac hint + document.querySelector(".mac-switch").classList.add("hidden"); +} + +function onTabClick(evt) { + // Get target and ID + const {triple, id} = evt.currentTarget.dataset; + if (triple) { + // Find corresponding content elements + const newContentEl = document.querySelector(`.install-content[data-id="${String(id)}"][data-triple=${triple}]`); + const oldContentEl = document.querySelector(`.install-content[data-triple=${triple}][data-id]:not(.hidden)`); + // Find old tab to unselect + const oldTabEl = document.querySelector(`.install-tab[data-triple=${triple}].selected`); + // Hide old content element + if (oldContentEl && oldTabEl) { + oldContentEl.classList.add("hidden"); + oldTabEl.classList.remove("selected"); + } + + // Unhide new content element + newContentEl.classList.remove("hidden"); + // Select new tab element + evt.currentTarget.classList.add("selected"); + } +} + +const allPlatforms = Array.from(document.querySelectorAll(`.arch[data-arch]`)); +let hit = allPlatforms.find( + (a) => { + // Show Intel Mac downloads if no M1 Mac downloads are available + if ( + a.attributes["data-arch"].value.includes(options.mac64) && + os.includes(options.macSilicon) && + !allPlatforms.find(p => p.attributes["data-arch"].value.includes(options.macSilicon))) { + // Unhide hint + document.querySelector(".mac-switch").classList.remove("hidden"); + return true; + } + return a.attributes["data-arch"].value.includes(os); + } +); + +if (hit) { + hit.classList.remove("hidden"); + const selectEl = document.querySelector("#install-arch-select"); + selectEl.value = hit.dataset.arch; + const firstContentChild = hit.querySelector(".install-content:first-of-type"); + const firstTabChild = hit.querySelector(".install-tab:first-of-type"); + firstContentChild.classList.remove("hidden"); + if (firstTabChild) { + firstTabChild.classList.add("selected"); + } +} else { + const noDetectEl = document.querySelector(".no-autodetect"); + if (noDetectEl) { + const noDetectElDetails = document.querySelector(".no-autodetect-details"); + if (noDetectElDetails) { + noDetectElDetails.innerHTML = `We detected you're on ${os} but there don't seem to be installers for that. ` + } + noDetectEl.classList.remove("hidden"); + } +} + +let copyButtons = Array.from(document.querySelectorAll("[data-copy]")); +if (copyButtons.length) { + copyButtons.forEach(function (element) { + element.addEventListener("click", () => { + navigator.clipboard.writeText(element.attributes["data-copy"].value); + }); + }); +} + +// Toggle for pre releases +const checkbox = document.getElementById("show-prereleases"); + +if (checkbox) { + checkbox.addEventListener("click", () => { + const all = document.getElementsByClassName("pre-release"); + + if (all) { + for (var item of all) { + item.classList.toggle("hidden"); + } + } + }); +} \ No newline at end of file diff --git a/coreutils/book/.nojekyll b/coreutils/book/.nojekyll new file mode 100644 index 000000000..f17311098 --- /dev/null +++ b/coreutils/book/.nojekyll @@ -0,0 +1 @@ +This file makes sure that Github Pages doesn't process mdBook's output. diff --git a/coreutils/book/404.html b/coreutils/book/404.html new file mode 100644 index 000000000..bf53ce15d --- /dev/null +++ b/coreutils/book/404.html @@ -0,0 +1,194 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +cargo, rustc)uutils follows Rust's release channels and is tested against stable, beta and
+nightly. The current Minimum Supported Rust Version (MSRV) is 1.64.0.
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
+
+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
+
+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'
+
+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.
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.
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
+
+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 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.
+To uninstall uutils:
+cargo uninstall uutils
+
+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
+
+
+ Contributions are very welcome via Pull Requests. If you don't know where to
+start, take a look at the
+good-first-issues.
+If you have any questions, feel free to ask them in the issues or on
+Discord.
info <utility>). It is more in depth than the man pages and
+provides a good description of available features and their implementation
+details.We take pride in supporting many operating systems and architectures. Any code
+you contribute must at least compile without warnings for all platforms in the
+CI. However, you can use #[cfg(...)] attributes to create platform dependent features.
Tip: For Windows, Microsoft provides some images (VMWare, Hyper-V, +VirtualBox and Parallels) for development: +https://developer.microsoft.com/windows/downloads/virtual-machines/
+We have an extensive CI that will check your code before it can be merged. This +section explains how to run those checks locally to avoid waiting for the CI.
+A configuration for pre-commit is provided in the repository. It allows
+automatically checking every git commit you make to ensure it compiles, and
+passes clippy and rustfmt without warnings.
To use the provided hook:
+pre-commitpre-commit install while in the repository directoryYour git commits will then automatically be checked. If a check fails, an error
+message will explain why, and your commit will be canceled. You can then make
+the suggested changes, and run git commit ... again.
cargo clippy --all-targets --all-features
+
+The msrv key in the clippy configuration file clippy.toml is used to disable
+lints pertaining to newer features by specifying the minimum supported Rust
+version (MSRV).
cargo fmt --all
+
+This project uses cargo-deny to +detect duplicate dependencies, checks licenses, etc. To run it locally, first +install it and then run with:
+cargo deny --all-features check all
+
+We use markdownlint to lint the +Markdown files in the repository.
+We use cspell as spell checker for all files in the project. If you are using
+VS Code, you can install the
+code spell checker
+extension to enable spell checking within your editor. Otherwise, you can
+install cspell separately.
If you want to make the spell checker ignore a word, you can add
++#![allow(unused)] +fn main() { +// spell-checker:ignore word_to_ignore +}
at the top of the file.
+Testing can be done using either Cargo or make.
Just like with building, we follow the standard procedure for testing using +Cargo:
+cargo test
+
+By default, cargo test only runs the common programs. To run also platform
+specific tests, run:
cargo test --features unix
+
+If you would prefer to test a select few utilities:
+cargo test --features "chmod mv tail" --no-default-features
+
+If you also want to test the core utilities:
+cargo test -p uucore -p coreutils
+
+Running the complete test suite might take a while. We use nextest in +the CI and you might want to try it out locally. It can speed up the execution time of the whole +test run significantly if the cpu has multiple cores.
+cargo nextest run --features unix --no-fail-fast
+
+To debug:
+gdb --args target/debug/coreutils ls
+(gdb) b ls.rs:79
+(gdb) run
+
+To simply test all available utilities:
+make test
+
+To test all but a few of the available utilities:
+make SKIP_UTILS='UTILITY_1 UTILITY_2' test
+
+To test only a few of the available utilities:
+make UTILS='UTILITY_1 UTILITY_2' test
+
+To include tests for unimplemented behavior:
+make UTILS='UTILITY_1 UTILITY_2' SPEC=y test
+
+To run tests with nextest just use the nextest target. Note you'll need to
+install nextest first. The nextest target accepts the
+same arguments like the default test target, so it's possible to pass arguments to nextest run
+via CARGOFLAGS:
make CARGOFLAGS='--no-fail-fast' UTILS='UTILITY_1 UTILITY_2' nextest
+
+This testing functionality is only available on *nix operating systems and
+requires make.
To run busybox tests for all utilities for which busybox has tests
+make busytest
+
+To run busybox tests for a few of the available utilities
+make UTILS='UTILITY_1 UTILITY_2' busytest
+
+To pass an argument like "-v" to the busybox test runtime
+make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest
+
+To run uutils against the GNU test suite locally, run the following commands:
+bash util/build-gnu.sh
+# Build uutils without release optimizations
+UU_MAKE_PROFILE=debug bash util/build-gnu.sh
+bash util/run-gnu-test.sh
+# To run a single test:
+bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example
+# To run several tests:
+bash util/run-gnu-test.sh tests/touch/not-owner.sh tests/rm/no-give-up.sh # for example
+# If this is a perl (.pl) test, to run in debug:
+DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl
+
+Note that it relies on individual utilities (not the multicall binary).
+The Python script ./util/remaining-gnu-error.py shows the list of failing
+tests in the CI.
To improve the GNU compatibility, the following process is recommended:
+./util/remaining-gnu-error.py script
+to help with this decision.bash util/build-gnu.shbash util/run-gnu-test.sh <your test><your test> to understand what is wrong. Examples:
+set -v to have the bash verbose modeecho $? where neededfail is used in the test, echo $fail to see when the
+test started to failcat err)To help the project maintainers review pull requests from contributors across +numerous utilities, the team has settled on conventions for commit messages.
+From https://git-scm.com/book/ch5-2.html:
+Capitalized, short (50 chars or less) summary
+
+More detailed explanatory text, if necessary. Wrap it to about 72
+characters or so. In some contexts, the first line is treated as the
+subject of an email and the rest of the text as the body. The blank
+line separating the summary from the body is critical (unless you omit
+the body entirely); tools like rebase will confuse you if you run the
+two together.
+
+Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
+or "Fixes bug." This convention matches up with commit messages generated
+by commands like git merge and git revert.
+
+Further paragraphs come after blank lines.
+
+ - Bullet points are okay, too
+
+ - Typically a hyphen or asterisk is used for the bullet, followed by a
+ single space, with blank lines in between, but conventions vary here
+
+ - Use a hanging indent
+
+Furthermore, here are a few examples for a summary line:
+nohup: cleanup and refactor
+
+tests/rm: test new feature
+
+Beyond changes to an individual utility or its tests, other summary +lines for non-utility modules include:
+README: add help
+
+uucore: add new modules
+
+uutils: add new utility
+
+gitignore: add temporary files
+
+Code coverage report can be generated using grcov.
+To generate gcov-based coverage report
+export CARGO_INCREMENTAL=0
+export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
+export RUSTDOCFLAGS="-Cpanic=abort"
+cargo build <options...> # e.g., --features feat_os_unix
+cargo test <options...> # e.g., --features feat_os_unix test_pathchk
+grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/
+# open target/debug/coverage/index.html in browser
+
+if changes are not reflected in the report then run cargo clean and run the above commands.
If you are using stable version of Rust that doesn't enable code coverage instrumentation by default
+then add -Z-Zinstrument-coverage flag to RUSTFLAGS env variable specified above.
The Coreutils have different implementations, with different levels of completions:
+ +However, when reimplementing the tools/options in Rust, don't read their source codes +when they are using reciprocal licenses (ex: GNU GPL, GNU LGPL, etc).
+uutils is distributed under the terms of the MIT License; see the LICENSE file
+for details. This is a permissive license, which allows the software to be used
+with few restrictions.
Copyrights in the uutils project are retained by their contributors, and no +copyright assignment is required to contribute.
+If you wish to add or change dependencies as part of a contribution to the
+project, a tool like cargo-license can be used to show their license details.
+The following types of license are acceptable:
Licenses we will not use:
+If you wish to add a reference but it doesn't meet these requirements, please +raise an issue to describe the dependency.
+ +Though the main goal of the project is compatibility, uutils supports a few +features that are not supported by GNU coreutils. We take care not to introduce +features that are incompatible with the GNU coreutils. Below is a list of uutils +extensions.
+GNU coreutils provides two ways to define short options taking an argument:
+$ ls -w 80
+$ ls -w80
+
+We support a third way:
+$ ls -w=80
+
+envenv has an additional -f/--file flag that can parse .env files and set
+variables accordingly. This feature is adopted from dotenv style packages.
cpcp can display a progress bar when the -g/--progress flag is set.
mvmv can display a progress bar when the -g/--progress flag is set.
hashsumThis utility does not exist in GNU coreutils. hashsum is a utility that
+supports computing the checksums with several algorithms. The flags and options
+are identical to the *sum family of utils (sha1sum, sha256sum, b2sum,
+etc.).
b3sumThis utility does not exist in GNU coreutils. The behavior is modeled after both
+the b2sum utility of GNU and the
+b3sum utility by the BLAKE3 team and
+supports the --no-names option that does not appear in the GNU util.
moreWe provide a simple implementation of more, which is not part of GNU
+coreutils. We do not aim for full compatibility with the more utility from
+util-linux. Features from more modern pagers (like less and bat) are
+therefore welcomed.
cutcut can separate fields by whitespace (Space and Tab) with -w flag. This
+feature is adopted from FreeBSD.
fmtfmt has additional flags for prefixes: -P/--skip-prefix, -x/--exact-prefix, and
+-X/--exact-skip-prefix. With -m/--preserve-headers, an attempt is made to detect and preserve
+mail headers in the input. -q/--quick breaks lines more quickly. And -T/--tab-width defines the
+number of spaces representing a tab when determining the line length.
seqseq provides -t/--terminator to set the terminator character.
lsGNU ls provides two ways to use a long listing format: -l and --format=long. We support a
+third way: --long.
dudu allows birth and creation as values for the --time argument to show the creation time.
uutils is an attempt at writing universal (as in cross-platform) CLI utilities +in Rust. It is available for Linux, Windows, Mac +and other platforms.
+The API reference for uucore, the library of functions shared between various
+utils, is hosted at docs.rs.
uutils is licensed under the +MIT License.
+++ +Note: This manual is automatically generated from the source code and is a +work in progress.
+