Note: original question posted on the RT users list. This is a follow-up
and possible solution.
Thanks to der Mouse for the shell tutorial.
I tried his suggestion and while I finally came to terms with my shell,
it confused the rt CLI. I was getting this with newlines:
rt: edit: No variables to set.
I messed around a bit and found that sticking the āxmsā at the end of
the regex seemed to make it work the way I wanted:
elsif (/^set$/i) {
my $vars = 0;
ā> while (@ARGV && $ARGV[0] =~ /^($field)([±]?=)(.*)$/xms) {
my ($key, $op, $val) = ($1, $2, $3);
What I donāt know is if this causes other un-wanted side effects with
multi-line commands, thus my post to the dev list. Would this be a
desired or worthwhile patch?
Thanks,
Jim
der Mouse wrote:
So youāre thinking I need to trick the shell into sending the proper
newline character?
Yes, though Iām not sure ātrickā is the best word.
I use tcsh,
Try
% echo āfoo
barā
that is, a real newline, inside single quotes, but also backslashed.
That works in all csh derivatives Iāve run into, including a real tcsh
(6.13.00) I happen to have access to. (I donāt use tcsh myself.)
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Jim Brandt
Administrative Computing Services
University at Buffalo
The patch was easy enough to generate, so itās included below. It allows
you to pass in a string with newlines via ārt createā.
I was able to run all of lib/t/regression/26command_line.t with this in
place and it didnāt appear to break anything. I tried to create a few
new tests for this case, but it turned out to be difficult to pass a
command with a newline through Test::Expect.
It allows newlines for other fields as well, but it doesnāt seem to
break things. I tried with subject and RT seems to handle it correctly.
It does seem to retain the '' and put it at the end of the subject
string. Maybe it would be better to allow newlines only for fields that
allow them?
while (@ARGV && $ARGV[0] =~ /^($field)([+-]?=)(.*)$/xms) {
while (@ARGV && $ARGV[0] =~ /^($field)([+-]?=)(.*)$/) {
my ($key, $op, $val) = ($1, $2, $3);
my $hash = ($op eq '=') ? \%set : ($op =~ /^\+/) ?
%add : %del;
Jim Brandt wrote:
Note: original question posted on the RT users list. This is a follow-up
and possible solution.
Thanks to der Mouse for the shell tutorial.
I tried his suggestion and while I finally came to terms with my shell,
it confused the rt CLI. I was getting this with newlines:
rt: edit: No variables to set.
I messed around a bit and found that sticking the āxmsā at the end of
the regex seemed to make it work the way I wanted:
elsif (/^set$/i) {
my $vars = 0;
ā> while (@ARGV && $ARGV[0] =~ /^($field)([±]?=)(.*)$/xms) {
my ($key, $op, $val) = ($1, $2, $3);
What I donāt know is if this causes other un-wanted side effects with
multi-line commands, thus my post to the dev list. Would this be a
desired or worthwhile patch?
Thanks,
Jim
der Mouse wrote:
So youāre thinking I need to trick the shell into sending the proper
newline character?
Yes, though Iām not sure ātrickā is the best word.
I use tcsh,
Try
% echo āfoo
barā
that is, a real newline, inside single quotes, but also backslashed.
That works in all csh derivatives Iāve run into, including a real tcsh
(6.13.00) I happen to have access to. (I donāt use tcsh myself.)
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Jim Brandt
Administrative Computing Services
University at Buffalo
Is there any way to pass in a new line character via the CLI? Iām trying
to put one in the text field with ācreateā and straight in with a ācommentā.
An actual return confuses the shell, and everything else I tried is
translated literally. \n and both just showed up that way in the
ticket. (Itās actually very cool that RT is translating everything
properly, but Iād like a control character to tell RT that I really want
a newline.)
Thanks,
Jim
Jim Brandt
Administrative Computing Services
University at Buffalo
We recently had an application that required us to import data containing newlines into our RT instance via the command-line tool. We found that the text field of the ācreateā option does not accept newlines, however adding an actual newline character to a ācommentā does:
[root@support ~]# /opt/rt3/bin/rt comment -m 'foo
barā 40849
Password:
Message recorded
[root@support ~]# echo $?
0
Sincerely,
Frank Pater
DCANet
voice: 888-4-DCANET (888-432-2638)
fax: 302-426-6386On Thu, Aug 31, 2006 at 12:07:00PM -0400, Jim Brandt wrote:
Is there any way to pass in a new line character via the CLI? Iām trying
to put one in the text field with ācreateā and straight in with a ācommentā.
An actual return confuses the shell, and everything else I tried is
translated literally. \n and both just showed up that way in the
ticket. (Itās actually very cool that RT is translating everything
properly, but Iād like a control character to tell RT that I really want
a newline.)
Thanks,
Jim
ā
Jim Brandt
Administrative Computing Services
University at Buffalo
Is there any way to pass in a new line character via the CLI? [ā¦]
An actual return confuses the shell,
This is a shell problem, then, and should be addressed as such. Every
shell Iāve used has a way to get a newline into a command argument -
though itās not always easy to find. Which shell do you use?
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B