mgirod / clearcase-cpan

Automatically exported from code.google.com/p/clearcase-cpan
0 stars 0 forks source link

Double quote problem in ClearCase::Argv #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

[shpichko@gibi ~]$ perl -e 'use ClearCase::Argv;
ClearCase::Argv->ctcmd(1);$ct=ClearCase::Argv->new({autochomp=>1});$a=$ct->argv(
qw(des
-fmt "%En\n%En@@%Vn\n%m\n%En@@%PVn"),"/vob/tools/common/perl")->qx;print"$a\n"'
"/vob/tools/common/perl
/vob/tools/common/perl@@/main/cif/5
directory version
/vob/tools/common/perl@@/main/cif/4"

What is the expected output? What do you see instead?

The expected output is the same as above, but without the double quotes,
i.e. the following:

/vob/tools/common/perl
/vob/tools/common/perl@@/main/cif/5
directory version
/vob/tools/common/perl@@/main/cif/4

The double quotes appear incorrectly in the command output.

What version of the product are you using? On what operating system?

ClearCase::Argv 1.36
Linux

This problem appears only if CtCmd Perl package is actually installed:

[shpichko@gibi]$ locate CtCmd.pm
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/ClearCase/CtCmd.pm

Please provide any additional information below.

On the host where CtCmd is not installed, ClearCase::Argv uses IPC mode
instead, and the problem does not appear: 

[shpichko@shadok ~]$ locate CtCmd.pm
[shpichko@shadok ~]$ 
[shpichko@shadok ~]$ perl -e 'use ClearCase::Argv;
ClearCase::Argv->ctcmd(1);$ct=ClearCase::Argv->new({autochomp=>1});$a=$ct->argv(
qw(des
-fmt "%En\n%En@@%Vn\n%m\n%En@@%PVn"),"/vob/tools/common/perl")->qx;print"$a\n"'
/vob/tools/common/perl
/vob/tools/common/perl@@/main/cif/5
directory version
/vob/tools/common/perl@@/main/cif/4

This ClearCase::Argv bug causes also e.g. incorrect behavior of lsgen
method in ClearCase::Wrapper::MGi (in ctcmd mode only).

Original issue reported on code.google.com by tanya.sh...@gmail.com on 18 Sep 2008 at 1:37

GoogleCodeExporter commented 9 years ago
When CtCmd is not available, ctcmd(1) defaults to 'fork', not 'ipc'mode, but 
all the
same. Thanks!

Original comment by marc.girod on 18 Sep 2008 at 1:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Succeeded to reproduce, on Windows, with CtCmd, fork, and ipc, from a script 
(thus
using double quotes):

N:\>perl c:\work\t.pl
\atcctest\.
\atcctest\.@@\main\mg\18
directory version
\atcctest\.@@\main\mg\17
"\atcctest\.
\atcctest\.@@\main\mg\18
directory version
\atcctest\.@@\main\mg\17"
"\atcctest\.
\atcctest\.@@\main\mg\18
directory version
\atcctest\.@@\main\mg\17"
"\atcctest\.
\atcctest\.@@\main\mg\18
directory version
\atcctest\.@@\main\mg\17"

Original comment by marc.girod on 23 Sep 2008 at 8:13

Attachments:

GoogleCodeExporter commented 9 years ago
A fix for the Windows side, in (plain) Argv.pm, r113

Original comment by marc.girod on 7 Oct 2008 at 6:08

GoogleCodeExporter commented 9 years ago
The fix is however too brutal, even on Windows. If I add the following to the 
script:

$ct->ipc(0);
$a=$ct->argv(qw(des -s "C:\\Program Files"))->qx;
print qq($a\n);

...I get as expected:

ClearCase::CtCmd: Error: Unable to access ""C:\Program": Invalid argument.
ClearCase::CtCmd: Error: Unable to access "Files"": Invalid argument.

Original comment by marc.girod on 8 Oct 2008 at 8:22

GoogleCodeExporter commented 9 years ago
Expected... apart maybe for the 'ClearCase::CtCmd:' part...

Original comment by marc.girod on 8 Oct 2008 at 8:24

GoogleCodeExporter commented 9 years ago
The last test addition is a coding bug: of course 'qw' will split 
'"C:\\Program' and
'Files"' into different arguments, and there is no point in trying to join them 
back.
This shows a limit to which this usage pattern argv(qw(...))->qx can and should 
be
supported, and abused (as a way to 'replace' the rejected argv("...")->qx.
So, even if one can consider mimicking unix/ipc in its support for some usage
patterns, into Windows/ctcmd, these should mabe be discouraged anyway...
I think of adding a 'quote' page to the wiki...

Original comment by marc.girod on 10 Oct 2008 at 9:04

GoogleCodeExporter commented 9 years ago
The syntax used in the test case is now considered incorrect...
One should use instead:

perl -e 'use ClearCase::Argv;
ClearCase::Argv->ctcmd(1);$ct=ClearCase::Argv->new({autochomp=>1});$a=$ct->argv(
qw(des
-fmt),'%En\n%En@@%Vn\n%m\n%En@@%PVn',"/vob/tools/common/perl")->qx;print"$a\n"'

I.e. not leave it to {{{qw}}} to decide how to parse and split the format.
This is impossible in the general case (similar proble as with comment 6).

Original comment by marc.girod on 22 Feb 2009 at 4:36