mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +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
|
// TODO: refactor the args and command matching
|
||||||
// See: https://github.com/uutils/coreutils/pull/2365#discussion_r647849967
|
// See: https://github.com/uutils/coreutils/pull/2365#discussion_r647849967
|
||||||
let command: Vec<&str> = match commands.len() {
|
let command: Vec<&str> = match commands.len() {
|
||||||
1 => {
|
0 => {
|
||||||
let shell: &str = match user_shell {
|
let shell: &str = match user_shell {
|
||||||
Err(_) => default_shell,
|
Err(_) => default_shell,
|
||||||
Ok(ref s) => s.as_ref(),
|
Ok(ref s) => s.as_ref(),
|
||||||
|
@ -79,10 +79,22 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
set_context(newroot, &matches);
|
set_context(newroot, &matches);
|
||||||
|
|
||||||
|
assert!(!command.is_empty());
|
||||||
let pstatus = Command::new(command[0])
|
let pstatus = Command::new(command[0])
|
||||||
.args(&command[1..])
|
.args(&command[1..])
|
||||||
.status()
|
.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() {
|
if pstatus.success() {
|
||||||
0
|
0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue