# HG changeset patch # User Robert McIntyre # Date 1360493938 18000 # Node ID 4823f88ea3b6b1870260628008c702540a8fb2c0 # Parent 6422228dfea75f2aa4b0df573535393bc6a6893c add -0 option to pkg-files. diff -r 6422228dfea7 -r 4823f88ea3b6 src/pkg-files.pl --- a/src/pkg-files.pl Sun Feb 10 05:52:35 2013 -0500 +++ b/src/pkg-files.pl Sun Feb 10 05:58:58 2013 -0500 @@ -1,11 +1,23 @@ #!/usr/bin/perl use File::stat; +$print0 = 0; + if ($ARGV[0] eq "--help"){ print <<"HERE"; pkg-examine -- print package contents. +usage: + pkg-examine -0 + +Prints the files which belong to the package user +. + +If the -0 option is given, prints all files belonging +to separated by null characters, as in the +"-print0" option of find. + Written by Robert McIntyre. This software is free software and is released to the public domain. @@ -14,7 +26,17 @@ } $" = " "; -$pkg_name = $ARGV[0]; + +if ($ARGV[0] eq "-0"){ + $print0 = 1; + $pkg_name = $ARGV[1]; +} +else { + $pkg_name = $ARGV[0]; +} + + + `id -g $pkg_name 2>/dev/null`; if (($pkg_name eq "") || $?){ @@ -22,7 +44,13 @@ exit 0; } -@files = split(/\0/, `find /usr /opt /etc -group $pkg_name -print0`); +$file_str = `find /usr /opt /etc -group $pkg_name -print0`; +if ($print0){ + print $file_str; + exit 0; +} + +@files = split(/\0/, $file_str); print "All files owned by this package:\n";