PerlPowerTools
view release on metacpan or search on metacpan
- simplify docs and correct some typos (#868)
* cal
- silence some warnings with better checks (#805)
* chgrp
- accept group ID argument (#798)
* chmod
- various internals improvements (#813)
- exit with 1 if a file fails (#814)
- check for redline failures and exit with failure code when they fail (#828)
- handle symbolic permissions correctly (#843)
* chown
- allow numeric UID argument (#804)
- allow for numeric group in user:group notation (#822)
* cmp
- better messages when files differ at end of file (#766)
* cp
- cp -i will continue to next file if there is an error. (#827)
* cut
- correctly handle "start, no end" (`n-`) range in `-b` (#783)
- handle -f consistently (#789)
* du
- handle bad arg count (#384)
- add the -d option (#385)
* baseb4
- check close return value (#362)
* bc
- use bignum with e notation (#353)
* cat
- Let -b override in (#360)
* cmp
- forbid -s with -l (#387)
* chown
- show filename in error message (#386)
* date
- show usage for bad options (#365)
* diff
- die if the args try to compare standard input to a directory (#361)
- improve options handling (#371)
- speedup some loops (#372)
* ed
- Adjust some error strings (#349)
- simplify code for r command (#354)
- don't print 0 for a false condition (#247)
- allow file named 0 (#282)
- fix case that eats too much input (#292)
* cal
- use getopts instead of custom parsing (#277)
* chgrp
- allow -- to end options (#341)
* chmod
- allow -- to end options (#347)
* chown
- allow -- to end options (#347)
* cmp
- exit with 2 on arg failure (#307)
- handle hex input (#309)
- support - for stdin (#310)
* col
- reject 0 value for -l (#334)
- add usage (#343)
* comm
- use strict (#306)
bin/banner
bin/base64
bin/basename
bin/bc
bin/bcd
bin/cal
bin/cat
bin/chgrp
bin/ching
bin/chmod
bin/chown
bin/clear
bin/cmp
bin/col
bin/colrm
bin/comm
bin/cp
bin/cut
bin/date
bin/dc
bin/deroff
( $uid, $gid, $mode, $modt ) = ( int( $attr->[2] ), int( $attr->[3] ), oct( $attr->[4] ), int( $attr->[1] ) );
}
my $out = FileHandle->new( $name, 'w' ) or die "$name: $!\n";
binmode($out);
$out->print( $attr->[6] );
$out->close();
# these might fail, but that's OK
chmod $mode, $name;
chown $uid, $gid, $name;
if ($settime) {
utime $modt, $modt, $name;
}
print "x - $name\n" if $verbose;
}
# read in a new file and return array ref of
# [ undef, $modt, $uid, $gid, $mode, $sz, $data ]
sub readFile {
File::Find::find (\&modify_file, readlink $file);
return;
}
my @st = stat $file;
unless (@st) {
warn "$Program: failed to stat '$file': $!\n";
$warnings++;
return;
};
my $uid = $st[4];
unless (chown $uid, $gid, $file) {
warn "$Program: '$file': $!\n";
$warnings++;
}
}
__END__
=pod
=head1 NAME
#!/usr/bin/perl
=begin metadata
Name: chown
Description: change ownership of files
Author: Abigail, perlpowertools@abigail.be
License: perl
=end metadata
=cut
use strict;
}
unless (defined $group) {
my @st = stat $file;
unless (@st) {
warn "$Program: failed to stat '$file': $!\n";
$rc = EX_FAILURE;
return;
}
$gid = $st[5];
}
unless (chown $uid, $gid, $file) {
warn "$Program: '$file': $!\n";
$rc = EX_FAILURE;
}
}
__END__
=pod
=head1 NAME
chown - change ownership of files
=head1 SYNOPSIS
chown [-R [-H | -L | -P]] user[:group] file [files ...]
=head1 DESCRIPTION
I<chown> sets the ownership of files. The first argument after the
options is either a I<user>, or a I<user>-I<group> pair, separated
by a colon. If the I<group> is given, group membership of the file
is changed as well.
=head2 OPTIONS
I<chown> accepts the options described below. The options I<-L>,
I<-H> and I<-P> are mutually exclusive, and only the last given
option will be honoured. All of I<-L>, I<-H> and I<-P> require the
I<-R> option to be set first.
=over 4
=item -R
Recurse into directories. Any directories are recursively traversed,
and all files and directories will change owner.
=item -L
Follow symbolic links. By default, I<chown> will not follow symbolic
links. This is a potential dangerous option, as I<chown> will not
check for cycles. Be careful. This option requires the I<-R> option to be set.
=item -H
Follow symbolic links of command line files/directories only. This option
requires the I<-R> option to be set.
=item -P
Do not follow symbolic links at all. This option requires the I<-R> option
to be set.
=back
=head1 ENVIRONMENT
The working of I<chown> is not influenced by any environment variables.
=head1 BUGS
I<chown> can loop forever when symbolic links create cycles.
I<chown> uses C<File::Find> to recurse.
=head1 REVISION HISTORY
$Log: chown,v $
Revision 1.2 2004/08/05 14:17:43 cwest
cleanup, new version number on website
Revision 1.1 2004/07/23 20:10:01 cwest
initial import
Revision 1.1 1999/02/28 19:59:17 abigail
Initial revision
=head1 AUTHOR
The Perl implementation of I<chown> was written by Abigail, I<perlpowertools@abigail.be>.
=head1 COPYRIGHT and LICENSE
This program is copyright by Abigail 1999.
This program is free and open software. You may use, copy, modify, distribute
and sell this program (and any modified variants) in any way you wish,
provided you do not restrict others to do the same.
=cut
bin/install view on Meta::CPAN
}
}
if (defined $opt{'o'} || defined $opt{'g'}) {
my @st = stat $path;
my $uid = $opt{'o'};
$uid = $st[4] unless defined $uid;
my $gid = $opt{'g'};
$gid = $st[5] unless defined $gid;
unless (chown $uid, $gid => $path) {
warn "$Program: chown $uid.$gid $path: $!\n";
$Errors++;
}
}
if ($opt{p}) {
unless (utime @{$st}[8,9] => $path) {
warn "$Program: utime $path: $!\n";
$Errors++;
}
}
bin/install view on Meta::CPAN
=head1 COPYRIGHT and LICENSE
Copyright 1999 UAH Information Technology and Systems Center.
This program is free and open software. You may use, copy, modify,
distribute, and sell this program (and any modified variants) in any way
you wish, provided you do not restrict others from doing the same.
=head1 SEE ALSO
umask(2), chmod(1), mkdir(1), chown(8), chgrp(8), strip(1)
=cut
lib/PerlPowerTools.pm view on Meta::CPAN
=item cal - display a calendar
=item cat - concatenate and print files.
=item chgrp - change group ownership of files
=item ching - the Book of Changes
=item chmod - change permissions of files.
=item chown - change ownership of files.
=item clear - clear the screen
=item cmp - compare two files
=item col - filter reverse line feeds from input
=item colrm - remove columns from a file
=item comm - select or reject lines common to two files
( run in 0.992 second using v1.01-cache-2.11-cpan-5511b514fd6 )