From: joeyh Date: Thu, 13 Jul 2006 21:10:34 +0000 (+0000) Subject: * vidir: Don't abort if it sees an empty or all-whitespace line. X-Git-Tag: 0.15~3 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3095ba17495d0f1871900fcc1c87e6efe9f55f18;p=moreutils * vidir: Don't abort if it sees an empty or all-whitespace line. * vidir: If just a filename is removed and the number is left, treat this the same as removing the whole line, and delete the file, instead of trying to rename the file to "". * vidir: Remove the periods after the item numbers. * vidir: Man page improvements. Closes: #378122 --- diff --git a/debian/changelog b/debian/changelog index 8b4eb28..679d7cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,14 @@ moreutils (0.15) UNRELEASED; urgency=low * Remove notes about potential tools from README, moved to wiki. - - -- Joey Hess Thu, 13 Jul 2006 12:21:38 -0400 + * vidir: Don't abort if it sees an empty or all-whitespace line. + * vidir: If just a filename is removed and the number is left, + treat this the same as removing the whole line, and delete the file, + instead of trying to rename the file to "". + * vidir: Remove the periods after the item numbers. + * vidir: Man page improvements. Closes: #378122 + + -- Joey Hess Thu, 13 Jul 2006 16:58:20 -0400 moreutils (0.14) unstable; urgency=low diff --git a/vidir b/vidir index 3e2f83a..f8227b1 100755 --- a/vidir +++ b/vidir @@ -11,9 +11,13 @@ B [--verbose] [directory|file|-] ... =head1 DESCRIPTION vidir allows editing of the contents of a directory in a text editor. If no -directory is specified, the current directory is edited. Each item in the -directory is listed. Delete items to remove them from the directory, or -edit their names to rename them. +directory is specified, the current directory is edited. + +When editing a directory, each item in the directory will appear on its own +numbered line. These numbers are how vidir keeps track of what items are +changed. Delete lines to remove files from the directory, or +edit filenames to rename files. You can also switch pairs of numbers to +swap filenames. Note that if "-" is specified as the directory to edit, it reads a list of filenames from stdin and displays those for editing. Alternatively, a list @@ -94,7 +98,7 @@ my $c=0; foreach (@dir) { next if /(.*\/)?\.$/ || /(.*\/)?\.\.$/; $item{++$c}=$_; - print OUT "$c.\t$_\n"; + print OUT "$c\t$_\n"; } @dir=(); close OUT; @@ -114,7 +118,7 @@ if ($ret != 0) { open (IN, $tmp->filename) || die "$0: cannot read ".$tmp->filename.": $!\n"; while () { chomp; - if (/^(\d+)\.\t(.*)/) { + if (/^(\d+)\t{0,1}(.*)/) { my $num=$1; my $name=$2; if (! exists $item{$num}) { @@ -122,6 +126,7 @@ while () { $error=1; } elsif ($name ne $item{$num}) { + next unless length $name; my $src=$item{$num}; # deal with swaps @@ -156,6 +161,9 @@ while () { } delete $item{$num}; } + elsif (/^\s*$/) { + # skip empty line + } else { die "$0: unable to parse line \"$_\", aborting\n"; }