Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/uu/nohup/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ nohup-after-help = If standard input is terminal, it'll be replaced with /dev/nu
If standard output is terminal, it'll be appended to nohup.out instead,
or $HOME/nohup.out, if nohup.out open failed.
If standard error is terminal, it'll be redirected to stdout.

# Error messages
nohup-error-cannot-detach = Cannot detach from console
nohup-error-cannot-replace = Cannot replace { $name }: { $err }
nohup-error-open-failed = failed to open { $path }: { $err }
nohup-error-open-failed-both = failed to open { $first_path }: { $first_err }\nfailed to open { $second_path }: { $second_err }

# Status messages
nohup-ignoring-input-appending-output = ignoring input and appending output to { $path }
16 changes: 16 additions & 0 deletions src/uu/nohup/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
nohup-about = Exécuter COMMANDE en ignorant les signaux de raccrochage.
nohup-usage = nohup COMMANDE [ARG]...
nohup OPTION
nohup-after-help = Si l'entrée standard est un terminal, elle sera remplacée par /dev/null.
Si la sortie standard est un terminal, elle sera ajoutée à nohup.out à la place,
ou $HOME/nohup.out, si l'ouverture de nohup.out a échoué.
Si l'erreur standard est un terminal, elle sera redirigée vers la sortie standard.

# Messages d'erreur
nohup-error-cannot-detach = Impossible de se détacher de la console
nohup-error-cannot-replace = Impossible de remplacer { $name } : { $err }
nohup-error-open-failed = échec de l'ouverture de { $path } : { $err }
nohup-error-open-failed-both = échec de l'ouverture de { $first_path } : { $first_err }\néchec de l'ouverture de { $second_path } : { $second_err }

# Messages de statut
nohup-ignoring-input-appending-output = entrée ignorée et sortie ajoutée à { $path }
35 changes: 22 additions & 13 deletions src/uu/nohup/src/nohup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use clap::{Arg, ArgAction, Command};
use libc::{SIG_IGN, SIGHUP};
use libc::{c_char, dup2, execvp, signal};
use std::collections::HashMap;
use std::env;
use std::ffi::CString;
use std::fs::{File, OpenOptions};
Expand All @@ -19,7 +20,8 @@
use uucore::error::{UClapError, UError, UResult, set_exit_code};
use uucore::{format_usage, show_error};

use uucore::locale::get_message;
use uucore::locale::{get_message, get_message_with_args};

static NOHUP_OUT: &str = "nohup.out";
// exit codes that match the GNU implementation
static EXIT_CANCELED: i32 = 125;
Expand All @@ -33,20 +35,21 @@

#[derive(Debug, Error)]
enum NohupError {
#[error("Cannot detach from console")]
#[error("{}", get_message("nohup-error-cannot-detach"))]
CannotDetach,

#[error("Cannot replace {name}: {err}", name = .0, err = .1)]
#[error("{}", get_message_with_args("nohup-error-cannot-replace", HashMap::from([("name".to_string(), _0.to_string()), ("err".to_string(), _1.to_string())])))]
CannotReplace(&'static str, #[source] Error),

#[error("failed to open {path}: {err}", path = NOHUP_OUT.quote(), err = .1)]
#[error("{}", get_message_with_args("nohup-error-open-failed", HashMap::from([("path".to_string(), NOHUP_OUT.quote().to_string()), ("err".to_string(), _1.to_string())])))]
OpenFailed(i32, #[source] Error),

#[error("failed to open {first_path}: {first_err}\nfailed to open {second_path}: {second_err}",
first_path = NOHUP_OUT.quote(),
first_err = .1,
second_path = .2.quote(),
second_err = .3)]
#[error("{}", get_message_with_args("nohup-error-open-failed-both", HashMap::from([
("first_path".to_string(), NOHUP_OUT.quote().to_string()),
("first_err".to_string(), _1.to_string()),
("second_path".to_string(), _2.quote().to_string()),
("second_err".to_string(), _3.to_string())
])))]
OpenFailed2(i32, #[source] Error, String, Error),
}

Expand Down Expand Up @@ -141,8 +144,11 @@
{
Ok(t) => {
show_error!(
"ignoring input and appending output to {}",
NOHUP_OUT.quote()
"{}",
get_message_with_args(
"nohup-ignoring-input-appending-output",
HashMap::from([("path".to_string(), NOHUP_OUT.quote().to_string())])

Check warning on line 150 in src/uu/nohup/src/nohup.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/nohup/src/nohup.rs#L147-L150

Added lines #L147 - L150 were not covered by tests
)
);
Ok(t)
}
Expand All @@ -157,8 +163,11 @@
match OpenOptions::new().create(true).append(true).open(&homeout) {
Ok(t) => {
show_error!(
"ignoring input and appending output to {}",
homeout_str.quote()
"{}",
get_message_with_args(
"nohup-ignoring-input-appending-output",
HashMap::from([("path".to_string(), homeout_str.quote().to_string())])

Check warning on line 169 in src/uu/nohup/src/nohup.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/nohup/src/nohup.rs#L166-L169

Added lines #L166 - L169 were not covered by tests
)
);
Ok(t)
}
Expand Down
Loading