[Rt-devel] [patch]: make command-line tool safe to be invoked with IO redirection

Otmar Lendl ol at bofh.priv.at
Fri Aug 22 09:27:48 EDT 2008


I was scripting using the command-line "rt" tool and needed to
do program a sequence like

* rt create -t ticket -e ...
* rt link ... 
* rt correspond

in a shell (or perl) script.

For the latter two invocations I need the ticket number of the
newly created ticket, which I can get by redirecting and parsing
STDOUT of "rt create".

This interferes with the -e option (or the error case) in which
an editor is called.

I fixed this with:

--- /usr/bin/rt 2007-10-31 11:52:20.000000000 +0100
+++ /usr/local/bin/rt 2008-08-20 14:14:20.000000000 +0200
@@ -1335,7 +1335,7 @@
local $/ = undef;

open(F, ">$file") || die "$file: $!\n"; print F $text; close(F);
- system($editor, $file) && die "Couldn't run $editor.\n";
+ system("$editor $file < /dev/tty > /dev/tty") && die "Couldn't run $editor.\n";
open(F, $file) || die "$file: $!\n"; $text = ; close(F);

Any better ideas?

-=-  Otmar Lendl  --  ol at bofh.priv.at  -=-

More information about the Rt-devel mailing list