mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-25 19:25:06 +00:00
when command is sent to background job and it exited. fish shell doesnot signify this error to user
This commit is contained in:
parent
5278259312
commit
4b16b9e1a1
2 changed files with 39 additions and 5 deletions
|
@ -29,6 +29,8 @@ function fish_job_summary -a job_id is_foreground cmd_line signal_or_end_name si
|
|||
|
||||
set -l message
|
||||
switch $signal_or_end_name
|
||||
case STATUS
|
||||
set message (printf ( _ "fish: Job %s, '%s' has Non Zero status code:%s\n" ) $job_id $cmd_line $signal_desc)
|
||||
case STOPPED
|
||||
set message (printf ( _ "fish: Job %s, '%s' has stopped\n" ) $job_id $cmd_line)
|
||||
case ENDED
|
||||
|
|
42
src/proc.rs
42
src/proc.rs
|
@ -1562,6 +1562,32 @@ fn proc_wants_summary(j: &Job, p: &Process) -> bool {
|
|||
true
|
||||
}
|
||||
|
||||
/// Return whether to emit a fish_job_summary call for a process.
|
||||
fn proc_wants_summary_in_job(j: &Job, p: &Process) -> bool {
|
||||
// Are we completed with a pid?
|
||||
if !p.is_completed() || !p.has_pid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// process failed with non zero status code.
|
||||
let s = &p.status;
|
||||
if s.status_value() != 0 {
|
||||
return true;
|
||||
}
|
||||
|
||||
if !s.signal_exited() || s.signal_code() == SIGPIPE {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does the job want to suppress notifications?
|
||||
// Note we always report crashes.
|
||||
if j.skip_notification() && !CRASHSIGNALS.contains(&s.signal_code()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
/// Return whether to emit a fish_job_summary call for a job as a whole. We may also emit this for
|
||||
/// its individual processes.
|
||||
fn job_wants_summary(j: &Job) -> bool {
|
||||
|
@ -1628,12 +1654,18 @@ fn summary_command(j: &Job, p: Option<&Process>) -> WString {
|
|||
Some(p) => {
|
||||
// We are summarizing a process which exited with a signal.
|
||||
// Arguments are the signal name and description.
|
||||
let sig = Signal::new(p.status.signal_code());
|
||||
buffer.push(' ');
|
||||
buffer += &escape(sig.name())[..];
|
||||
if p.status.normal_exited(){
|
||||
buffer += L!("STATUS");
|
||||
buffer.push(' ');
|
||||
buffer.push_str(&format!("{}", p.status.status_value()));
|
||||
} else{
|
||||
let sig = Signal::new(p.status.signal_code());
|
||||
buffer += &escape(sig.name())[..];
|
||||
buffer.push(' ');
|
||||
buffer += &escape(sig.desc())[..];
|
||||
}
|
||||
|
||||
buffer.push(' ');
|
||||
buffer += &escape(sig.desc())[..];
|
||||
|
||||
// If we have multiple processes, we also append the pid and argv.
|
||||
if j.processes().len() > 1 {
|
||||
|
@ -1661,7 +1693,7 @@ fn summarize_jobs(parser: &Parser, jobs: &[JobRef]) -> bool {
|
|||
} else {
|
||||
// Completed job.
|
||||
for p in j.processes().iter() {
|
||||
if proc_wants_summary(j, p) {
|
||||
if proc_wants_summary_in_job(j, p) {
|
||||
call_job_summary(parser, &summary_command(j, Some(p)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue