mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-18 20:53:40 +08: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
|
@ -80,7 +80,6 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
|||
retval = STATUS_CMD_ERROR;
|
||||
}
|
||||
} else {
|
||||
// TODO: This is supposed to be deduplicated or a hash set per comments below!
|
||||
let mut jobs = vec![];
|
||||
|
||||
retval = STATUS_CMD_OK;
|
||||
|
@ -116,6 +115,11 @@ pub fn disown(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
|||
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.
|
||||
for j in jobs {
|
||||
disown_job(cmd, streams, &j);
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
|
|||
#[repr(transparent)]
|
||||
pub struct JobId(NonZeroU32);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct MaybeJobId(pub Option<JobId>);
|
||||
|
||||
impl std::ops::Deref for MaybeJobId {
|
||||
|
|
Loading…
Reference in New Issue
Block a user