[interchange-cvs] interchange - jon modified eg/te

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sat Apr 12 02:33:40 UTC 2008


User:      jon
Date:      2008-04-12 02:33:40 GMT
Modified:  eg       te
Log:
Add new -o option, by Greg Sabino Mullane.

Also remove debugging of editor quoting in error message that made
for an incorrect message.

And clean up some documentation.

Revision  Changes    Path
2.13                 interchange/eg/te


rev 2.13, prev_rev 2.12
Index: te
===================================================================
RCS file: /var/cvs/interchange/eg/te,v
retrieving revision 2.12
retrieving revision 2.13
diff -u -u -r2.12 -r2.13
--- te	27 Dec 2005 18:15:33 -0000	2.12
+++ te	12 Apr 2008 02:33:40 -0000	2.13
@@ -5,7 +5,7 @@
 =head1 NAME
 
 te (table editor) - front-end that simplifies editing tab-delimited
-ASCII tables
+text tables
 
 =head1 SYNOPSIS
 
@@ -49,7 +49,7 @@
 
 =item o
 
-To delete a column, delete it's line in the first record.
+To delete a column, delete its line in the first record.
 
 =item o
 
@@ -101,19 +101,14 @@
 Options will also be read from environment variable TE_OPTIONS if it is
 set.
 
-=head1 LIMITATIONS
-
-There is currently no way to add or delete entire columns from the
-file. I recommend using B<cut>(1) for this.
-
 =head1 AUTHOR
 
-Jon Jensen <jon at icdevgroup.org>
+Jon Jensen <jon at endpoint.com>
 
 =head1 COPYRIGHT
 
-Copyright (C) 2002-2005 Jon Jensen and Mike Heins
-Copyright (C) 2001-2002 Red Hat, Inc.
+    Copyright (C) 2002-2008 Jon Jensen and others
+    Copyright (C) 2001-2002 Red Hat, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -127,7 +122,7 @@
 
 =head1 VERSION
 
-$Id: te,v 2.12 2005-12-27 18:15:33 jon Exp $
+$Id: te,v 2.13 2008-04-12 02:33:40 jon Exp $
 
 =head1 CHANGELOG
 
@@ -171,6 +166,9 @@
 2005-11-15. Added support for extended columns containing Perl
 serialized hashes with the -e option.
 
+2008-04-11. Added option -o to write output to a file and exit, never
+invoking an editor. By Greg Sabino Mullane.
+
 =cut
 
 use strict;
@@ -189,10 +187,11 @@
 
 Options:
     -i       Ignores case on vim jump search.
-    -s TEXT  Jumps to first line where TEXT is. Only for vim.
+    -s TEXT  Jumps to first line where TEXT is. Only for vi.
     -f       Do not look for field names on first line of file.
     -n       Number rows in comments
     -e field Extra fields in this field, a stringified hash
+    -o FILE  Convert to the named output file and exit
 
 See 'man te' or 'perldoc $0' for more information.
 
@@ -201,8 +200,8 @@
 unshift @ARGV, Text::ParseWords::shellwords($ENV{TE_OPTIONS})
 	if defined $ENV{TE_OPTIONS};
 
-use vars qw/$opt_i $opt_s $opt_f $opt_n $opt_e/;
-getopts('is:fne:') or die "$@\n$USAGE";
+use vars qw/$opt_i $opt_s $opt_f $opt_n $opt_e $opt_o/;
+getopts('is:fne:o:') or die "$@\n$USAGE";
 
 die $USAGE unless @ARGV;
 
@@ -261,6 +260,17 @@
 	# was a 12 MB products.txt table for Interchange.)
 
 	$tmpfile = "$path.$name.tmp.$$";
+	if ($opt_o) {
+		if (-e $opt_o) {
+			print "Overwrite $opt_o? ";
+			my $ans = <STDIN>;
+			if ($ans !~ /^Y/i) {
+				print "\nFile not overwritten, exiting.\n";
+				exit;
+			}
+		}
+		$tmpfile = $opt_o;
+	}
 	open OUT, ">$tmpfile" or die "Error opening '$tmpfile' for writing: $!\n";
 	print STDERR "Prettifying $filename\n";
 	print OUT <<EOF;
@@ -329,13 +339,17 @@
 #
 EOF
 	close OUT or die "Error closing '$tmpfile' after writing: $!\n";
+	if ($opt_o) {
+		print "Wrote $opt_o\n";
+		exit;
+	}
+
 	open IN, "<$tmpfile" or die "Error opening '$tmpfile' for reading: $!\n";
 	binmode IN;
 	$digest1 = Digest::MD5->new->addfile(*IN)->digest;
 	close IN;
 	system (@ED, $tmpfile) == 0
 		or do {
-			@ED = ('gvim', '-f', 'some quotes " "', "some space");
 			for(@ED) {
 				next unless /\s/;
 				s/"/\\"/g;







More information about the interchange-cvs mailing list