mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
coreutils: Remove limitation for prefix
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
+11
-17
@@ -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 {
|
||||
|
||||
+3
-5
@@ -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}' ]"
|
||||
|
||||
Reference in New Issue
Block a user