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
3 changes: 1 addition & 2 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult

for source in sources {
let normalized_source = normalize_path(source);
if options.backup == BackupMode::None && seen_sources.contains(&normalized_source) {
if options.backup == BackupMode::None && !seen_sources.insert(normalized_source) {
let file_type = if source.symlink_metadata()?.file_type().is_dir() {
"directory"
} else {
Expand Down Expand Up @@ -1538,7 +1538,6 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
copied_destinations.insert(dest.clone());
}
}
seen_sources.insert(normalized_source);
}

if let Some(pb) = progress_bar {
Expand Down
30 changes: 13 additions & 17 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,11 @@ fn safe_du(
}

// Handle inodes
if let Some(inode) = this_stat.inode {
if seen_inodes.contains(&inode) && !options.count_links {
continue;
}
seen_inodes.insert(inode);
if let Some(inode) = this_stat.inode
&& !seen_inodes.insert(inode)
&& !options.count_links
{
continue;
}

// Process directories recursively
Expand Down Expand Up @@ -702,14 +702,11 @@ fn du_regular(
}
}

if let Some(inode) = this_stat.inode {
// Check if the inode has been seen before and if we should skip it
if seen_inodes.contains(&inode) && !options.count_links {
// Skip further processing for this inode
continue;
}
// Mark this inode as seen
seen_inodes.insert(inode);
if let Some(inode) = this_stat.inode
&& !seen_inodes.insert(inode)
&& !options.count_links
{
continue;
}

if this_stat.metadata.is_dir() {
Expand Down Expand Up @@ -1202,11 +1199,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let stat = Stat::new(&path, None, &traversal_options);
if let Ok(stat) = stat.as_ref()
&& let Some(inode) = stat.inode
&& !traversal_options.count_links
&& !seen_inodes.insert(inode)
{
if !traversal_options.count_links && seen_inodes.contains(&inode) {
continue 'loop_file;
}
seen_inodes.insert(inode);
continue 'loop_file;
}

if use_safe_traversal {
Expand Down
3 changes: 1 addition & 2 deletions src/uu/hostname/src/hostname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,14 @@ fn display_hostname(matches: &ArgMatches) -> UResult<()> {
let mut output = String::new();
for addr in addresses {
// XXX: not sure why this is necessary...
if !hashset.contains(&addr) {
if hashset.insert(addr) {
let mut ip = addr.to_string();
if ip.ends_with(":1") {
let len = ip.len();
ip.truncate(len - 2);
}
output.push_str(&ip);
output.push(' ');
hashset.insert(addr);
}
}
let len = output.len();
Expand Down
Loading