From 6adc10b9b497fbecc4bcfdf91008b2063e72fe10 Mon Sep 17 00:00:00 2001 From: short <> Date: Sun, 27 Jan 2002 15:28:16 +0000 Subject: [PATCH] Implemented keeping of comment-blocks between two lines matching /^$!/ - needed by /etc/cron.*/.cvslinks files to prevent crond errors [cs_CZ] Implementovano zachovani komentarovych bloku mezi radky matchujicimi /^$!/ - potrebne pro soubory /etc/cron.*/.cvslinks pro predejiti chyb od crond --- bin/cvslinks | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bin/cvslinks b/bin/cvslinks index c96248e..9f77734 100755 --- a/bin/cvslinks +++ b/bin/cvslinks @@ -57,9 +57,12 @@ sub do_u open L,FILENAME or die "File ".FILENAME." cannot be opened: $!"; do_d(); verbose "Creating links from ".FILENAME; + my $cmt=0; while () { chomp; - next if /^$/; # empty-file (->empty-dir) stub line + my $cmt_old=$cmt; + $cmt=!$cmt if /^#!/; + next if $cmt || $cmt_old || /^$/; # comment or empty-file (->empty-dir) stub line /^(.+)\t(.+)$/ or warn "Unrecognized line: $_"; verbose "Creating link $1"; symlink $2,$1 or warn "symlink(\"$2\"->\"$1\"): $!"; @@ -71,9 +74,21 @@ sub do_c { local(*L,*D); opendir D,"." or die "Cannot open directory \".\": $!"; - open L,">".FILENAME or die "File ".FILENAME." cannot be created: $!"; verbose "Storing links to ".FILENAME; - print L "\n"; # empty-file (->empty-dir) stub line + my $cmtblock=""; + if (open L,FILENAME) { + my $cmt=0; + while () { + my $cmt_old=$cmt; + $cmt=!$cmt if /^#!/; + next unless $cmt || $cmt_old; # comment + $cmtblock.=$_; + } + close L; + } + $cmtblock="\n" if !$cmtblock; # empty-file (->empty-dir) stub line + open L,">".FILENAME or die "File ".FILENAME." cannot be created: $!"; + print L $cmtblock; for (readdir D) { next if ! -l; my $target=readlink or die "Cannot read link $_: $!"; @@ -81,6 +96,7 @@ sub do_c print L "$_\t$target\n"; } closedir D; + close L; } sub descent -- 1.8.3.1