mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 18:28:18 +00:00
chroot
: quick fix for #2687
* fixes #2687 * change error message to better mimic GNU
This commit is contained in:
parent
8d418cd61c
commit
94fbe1edef
1 changed files with 14 additions and 2 deletions
|
@ -67,7 +67,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
// TODO: refactor the args and command matching
|
||||
// See: https://github.com/uutils/coreutils/pull/2365#discussion_r647849967
|
||||
let command: Vec<&str> = match commands.len() {
|
||||
1 => {
|
||||
0 => {
|
||||
let shell: &str = match user_shell {
|
||||
Err(_) => default_shell,
|
||||
Ok(ref s) => s.as_ref(),
|
||||
|
@ -79,10 +79,22 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
|
||||
set_context(newroot, &matches);
|
||||
|
||||
assert!(!command.is_empty());
|
||||
let pstatus = Command::new(command[0])
|
||||
.args(&command[1..])
|
||||
.status()
|
||||
.unwrap_or_else(|e| crash!(1, "Cannot exec: {}", e));
|
||||
.unwrap_or_else(|e| {
|
||||
// TODO: Exit status:
|
||||
// 125 if chroot itself fails
|
||||
// 126 if command is found but cannot be invoked
|
||||
// 127 if command cannot be found
|
||||
crash!(
|
||||
1,
|
||||
"failed to run command {}: {}",
|
||||
command[0].to_string().quote(),
|
||||
e
|
||||
)
|
||||
});
|
||||
|
||||
if pstatus.success() {
|
||||
0
|
||||
|
|
Loading…
Reference in a new issue