Skip to content

Commit

Permalink
ar: warn if archive member isn't found (#500)
Browse files Browse the repository at this point in the history
* ar -p mode with no arguments prints all members of the archive to standard output
* ar -p can be given explicit member names to print
* If I type the wrong member name GNU ar gives me a warning an proceeds to print the next member argument
* Example: "perl ar -p new.ar notfound asa" --> print warning on stderr for notfound not being found, then print content of archive member asa on stdout
  • Loading branch information
mknos committed Mar 13, 2024
1 parent 99224af commit 01e47d2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/ar
Expand Up @@ -179,10 +179,13 @@ exit 0;
sub printMember {
my ($name, $pAr, $verbose) = @_;

print "\n<$name>\n\n" if $verbose;

# dump the data
print $pAr->{$name}[6];
if (exists $pAr->{$name}) {
print "\n<$name>\n\n" if $verbose;
print $pAr->{$name}[6];
}
else {
warn "entry not found in archive: '$name'\n";
}
}

# writes a directory-style listing for the specified archive member
Expand Down

0 comments on commit 01e47d2

Please sign in to comment.