Skip to content

Commit 0a763be

Browse files
committed
coreutils: Remove limitation for prefix
1 parent 5fd3459 commit 0a763be

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ To install every program with a prefix (e.g. uu-echo uu-cat):
227227
make PROG_PREFIX=uu- install
228228
```
229229

230-
`PROG_PREFIX` requires separator `-`, `_`, or `=`.
231-
232230
To install the multicall binary:
233231

234232
```shell

src/bin/coreutils.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,18 @@ fn main() {
5252
process::exit(0);
5353
});
5454

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

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

7468
// 0th argument equals util name?
7569
if let Some(util_os) = util_name {

util/build-gnu.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,17 @@ fi
8888
cd -
8989

9090
export CARGOFLAGS # tell to make
91-
"${MAKE}" UTILS=install
92-
[ -e "${UU_BUILD_DIR}/ginstall" ] || ln -vf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use renamed install to ginstall
9391
if [ "${SELINUX_ENABLED}" = 1 ];then
9492
# Build few utils for SELinux for faster build. MULTICALL=y fails...
95-
"${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"
93+
"${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"
9694
else
9795
# Use MULTICALL=y for faster build
98-
"${MAKE}" MULTICALL=y SKIP_UTILS="install more"
96+
"${MAKE}" MULTICALL=y SKIP_UTILS=more
9997
for binary in $("${UU_BUILD_DIR}"/coreutils --list)
10098
do [ -e "${UU_BUILD_DIR}/${binary}" ] || ln -vf "${UU_BUILD_DIR}/coreutils" "${UU_BUILD_DIR}/${binary}"
10199
done
102100
fi
103-
101+
[ -e "${UU_BUILD_DIR}/ginstall" ] || ln -vf "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests use renamed install to ginstall
104102
##
105103

106104
cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"

0 commit comments

Comments
 (0)