⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ To install every program with a prefix (e.g. uu-echo uu-cat):
make PROG_PREFIX=uu- install
```

`PROG_PREFIX` requires separator `-`, `_`, or `=`.

To install the multicall binary:

```shell
Expand Down
6 changes: 6 additions & 0 deletions docs/src/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ $ ls -w=80
With GNU coreutils, `--help` usually prints the help message and `--version` prints the version.
We also commonly provide short options: `-h` for help and `-V` for version.

## `coreutils`

Our `coreutils` calls utility by `coreutils utility-name` and has `--list` to run against busybox test suite.
Our `coreutils` is called as `utility-name` if its binary name ends with `utility-name` to support prefixed names.
Longer name is prioritized e.g. `sum` with the prefix `ck` is called as `cksum`.

## `env`

GNU `env` allows the empty string to be used as an environment variable name.
Expand Down
28 changes: 11 additions & 17 deletions src/bin/coreutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,18 @@ fn main() {
process::exit(0);
});

// binary name equals util name?
if let Some(&(uumain, _)) = utils.get(binary_as_util) {
validation::setup_localization_or_exit(binary_as_util);
process::exit(uumain(vec![binary.into()].into_iter().chain(args)));
}
// binary name ends with util name?
let matched_util = utils
.keys()
.filter(|&&u| binary_as_util.ends_with(u) && !binary_as_util.ends_with("coreutils"))
.max_by_key(|u| u.len()); //Prefer stty more than tty. coreutils is not ls

// binary name equals prefixed util name?
// * prefix/stem may be any string ending in a non-alphanumeric character
// For example, if the binary is named `uu_test`, it will match `test` as a utility.
let util_name =
if let Some(util) = validation::find_prefixed_util(binary_as_util, utils.keys().copied()) {
// prefixed util => replace 0th (aka, executable name) argument
Some(OsString::from(util))
} else {
// unmatched binary name => regard as multi-binary container and advance argument list
uucore::set_utility_is_second_arg();
args.next()
};
let util_name = if let Some(&util) = matched_util {
Some(OsString::from(util))
} else {
uucore::set_utility_is_second_arg();
args.next()
};

// 0th argument equals util name?
if let Some(util_os) = util_name {
Expand Down
8 changes: 3 additions & 5 deletions util/build-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,17 @@ fi
cd -

export CARGOFLAGS # tell to make
"${MAKE}" UTILS=install
[ -e "${UU_BUILD_DIR}/ginstall" ] || ln -vf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use renamed install to ginstall
if [ "${SELINUX_ENABLED}" = 1 ];then
# Build few utils for SELinux for faster build. MULTICALL=y fails...
"${MAKE}" UTILS="cat chcon chmod cp cut dd echo env groups id ln ls mkdir mkfifo mknod mktemp mv printf rm rmdir runcon seq stat test touch tr true uname wc whoami"
"${MAKE}" UTILS="cat chcon chmod cp cut dd echo env groups id install ln ls mkdir mkfifo mknod mktemp mv printf rm rmdir runcon seq stat test touch tr true uname wc whoami"
else
# Use MULTICALL=y for faster build
"${MAKE}" MULTICALL=y SKIP_UTILS="install more"
"${MAKE}" MULTICALL=y SKIP_UTILS=more
for binary in $("${UU_BUILD_DIR}"/coreutils --list)
do [ -e "${UU_BUILD_DIR}/${binary}" ] || ln -vf "${UU_BUILD_DIR}/coreutils" "${UU_BUILD_DIR}/${binary}"
done
fi

[ -e "${UU_BUILD_DIR}/ginstall" ] || ln -vf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use renamed install to ginstall
##

cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
Expand Down
Loading