mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
Deduplicate jobs passed to disown
builtin
I'm guessing this was missed in the port because there were comments referencing using a hash set to perform the deduplication but there was no hashset. (The TODO was added later.)
This commit is contained in:
parent
366c1b7210
commit
c1acbf2845
2 changed files with 6 additions and 2 deletions
|
@ -80,7 +80,6 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
||||||
retval = STATUS_CMD_ERROR;
|
retval = STATUS_CMD_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: This is supposed to be deduplicated or a hash set per comments below!
|
|
||||||
let mut jobs = vec![];
|
let mut jobs = vec![];
|
||||||
|
|
||||||
retval = STATUS_CMD_OK;
|
retval = STATUS_CMD_OK;
|
||||||
|
@ -116,6 +115,11 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// One PID/JID may be repeated or multiple PIDs may refer to the same job;
|
||||||
|
// include the job only once.
|
||||||
|
jobs.sort_unstable_by_key(|job| job.job_id());
|
||||||
|
jobs.dedup_by_key(|job| job.job_id());
|
||||||
|
|
||||||
// Disown all target jobs.
|
// Disown all target jobs.
|
||||||
for j in jobs {
|
for j in jobs {
|
||||||
disown_job(cmd, streams, &j);
|
disown_job(cmd, streams, &j);
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct JobId(NonZeroU32);
|
pub struct JobId(NonZeroU32);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
pub struct MaybeJobId(pub Option<JobId>);
|
pub struct MaybeJobId(pub Option<JobId>);
|
||||||
|
|
||||||
impl std::ops::Deref for MaybeJobId {
|
impl std::ops::Deref for MaybeJobId {
|
||||||
|
|
Loading…
Reference in a new issue