mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #8117 from sylvestre/l10n-timeout
l10n: port timeout for translation + add french
This commit is contained in:
commit
d7701c0960
3 changed files with 62 additions and 20 deletions
|
@ -1,2 +1,16 @@
|
|||
timeout-about = Start COMMAND, and kill it if still running after DURATION.
|
||||
timeout-usage = timeout [OPTION] DURATION COMMAND...
|
||||
|
||||
# Help messages
|
||||
timeout-help-foreground = when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out
|
||||
timeout-help-kill-after = also send a KILL signal if COMMAND is still running this long after the initial signal was sent
|
||||
timeout-help-preserve-status = exit with the same status as COMMAND, even when the command times out
|
||||
timeout-help-signal = specify the signal to be sent on timeout; SIGNAL may be a name like 'HUP' or a number; see 'kill -l' for a list of signals
|
||||
timeout-help-verbose = diagnose to stderr any signal sent upon timeout
|
||||
|
||||
# Error messages
|
||||
timeout-error-invalid-signal = { $signal }: invalid signal
|
||||
timeout-error-failed-to-execute-process = failed to execute process: { $error }
|
||||
|
||||
# Verbose messages
|
||||
timeout-verbose-sending-signal = sending signal { $signal } to command { $command }
|
||||
|
|
16
src/uu/timeout/locales/fr-FR.ftl
Normal file
16
src/uu/timeout/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,16 @@
|
|||
timeout-about = Démarrer COMMANDE, et la tuer si elle fonctionne encore après DURÉE.
|
||||
timeout-usage = timeout [OPTION] DURÉE COMMANDE...
|
||||
|
||||
# Messages d'aide
|
||||
timeout-help-foreground = quand on n'exécute pas timeout directement depuis une invite de shell, permettre à COMMANDE de lire depuis le TTY et d'obtenir les signaux TTY ; dans ce mode, les enfants de COMMANDE ne seront pas limités dans le temps
|
||||
timeout-help-kill-after = envoyer aussi un signal KILL si COMMANDE fonctionne encore si longtemps après que le signal initial ait été envoyé
|
||||
timeout-help-preserve-status = sortir avec le même statut que COMMANDE, même quand la commande dépasse le délai
|
||||
timeout-help-signal = spécifier le signal à envoyer en cas de délai dépassé ; SIGNAL peut être un nom comme 'HUP' ou un nombre ; voir 'kill -l' pour une liste des signaux
|
||||
timeout-help-verbose = diagnostiquer vers stderr tout signal envoyé lors d'un dépassement de délai
|
||||
|
||||
# Messages d'erreur
|
||||
timeout-error-invalid-signal = { $signal } : signal invalide
|
||||
timeout-error-failed-to-execute-process = échec d'exécution du processus : { $error }
|
||||
|
||||
# Messages détaillés
|
||||
timeout-verbose-sending-signal = envoi du signal { $signal } à la commande { $command }
|
|
@ -8,6 +8,7 @@ mod status;
|
|||
|
||||
use crate::status::ExitStatus;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::collections::HashMap;
|
||||
use std::io::ErrorKind;
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::process::{self, Child, Stdio};
|
||||
|
@ -17,7 +18,7 @@ use uucore::error::{UClapError, UResult, USimpleError, UUsageError};
|
|||
use uucore::parser::parse_time;
|
||||
use uucore::process::ChildExt;
|
||||
|
||||
use uucore::locale::get_message;
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
#[cfg(unix)]
|
||||
use uucore::signals::enable_pipe_errors;
|
||||
|
||||
|
@ -58,7 +59,13 @@ impl Config {
|
|||
None => {
|
||||
return Err(UUsageError::new(
|
||||
ExitStatus::TimeoutFailed.into(),
|
||||
format!("{}: invalid signal", signal_.quote()),
|
||||
get_message_with_args(
|
||||
"timeout-error-invalid-signal",
|
||||
HashMap::from([(
|
||||
"signal".to_string(),
|
||||
signal_.quote().to_string(),
|
||||
)]),
|
||||
),
|
||||
));
|
||||
}
|
||||
Some(signal_value) => signal_value,
|
||||
|
@ -126,44 +133,34 @@ pub fn uu_app() -> Command {
|
|||
Arg::new(options::FOREGROUND)
|
||||
.long(options::FOREGROUND)
|
||||
.short('f')
|
||||
.help(
|
||||
"when not running timeout directly from a shell prompt, allow \
|
||||
COMMAND to read from the TTY and get TTY signals; in this mode, \
|
||||
children of COMMAND will not be timed out",
|
||||
)
|
||||
.help(get_message("timeout-help-foreground"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::KILL_AFTER)
|
||||
.long(options::KILL_AFTER)
|
||||
.short('k')
|
||||
.help(
|
||||
"also send a KILL signal if COMMAND is still running this long \
|
||||
after the initial signal was sent",
|
||||
),
|
||||
.help(get_message("timeout-help-kill-after")),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PRESERVE_STATUS)
|
||||
.long(options::PRESERVE_STATUS)
|
||||
.short('p')
|
||||
.help("exit with the same status as COMMAND, even when the command times out")
|
||||
.help(get_message("timeout-help-preserve-status"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::SIGNAL)
|
||||
.short('s')
|
||||
.long(options::SIGNAL)
|
||||
.help(
|
||||
"specify the signal to be sent on timeout; SIGNAL may be a name like \
|
||||
'HUP' or a number; see 'kill -l' for a list of signals",
|
||||
)
|
||||
.help(get_message("timeout-help-signal"))
|
||||
.value_name("SIGNAL"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::VERBOSE)
|
||||
.short('v')
|
||||
.long(options::VERBOSE)
|
||||
.help("diagnose to stderr any signal sent upon timeout")
|
||||
.help(get_message("timeout-help-verbose"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(Arg::new(options::DURATION).required(true))
|
||||
|
@ -192,7 +189,16 @@ fn unblock_sigchld() {
|
|||
fn report_if_verbose(signal: usize, cmd: &str, verbose: bool) {
|
||||
if verbose {
|
||||
let s = signal_name_by_value(signal).unwrap();
|
||||
show_error!("sending signal {s} to command {}", cmd.quote());
|
||||
show_error!(
|
||||
"{}",
|
||||
get_message_with_args(
|
||||
"timeout-verbose-sending-signal",
|
||||
HashMap::from([
|
||||
("signal".to_string(), s.to_string()),
|
||||
("command".to_string(), cmd.quote().to_string())
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +321,13 @@ fn timeout(
|
|||
// FIXME: this may not be 100% correct...
|
||||
126
|
||||
};
|
||||
USimpleError::new(status_code, format!("failed to execute process: {err}"))
|
||||
USimpleError::new(
|
||||
status_code,
|
||||
get_message_with_args(
|
||||
"timeout-error-failed-to-execute-process",
|
||||
HashMap::from([("error".to_string(), err.to_string())]),
|
||||
),
|
||||
)
|
||||
})?;
|
||||
unblock_sigchld();
|
||||
// Wait for the child process for the specified time period.
|
||||
|
@ -364,7 +376,7 @@ fn timeout(
|
|||
Ok(status) => Err(status.into()),
|
||||
Err(e) => Err(USimpleError::new(
|
||||
ExitStatus::TimeoutFailed.into(),
|
||||
format!("{e}"),
|
||||
e.to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue