Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: cvs wrapper with ssh-agent

by blazar (Canon)
on Sep 19, 2008 at 18:06 UTC ( #712568=note: print w/replies, xml ) Need Help??

in reply to cvs wrapper with ssh-agent

open DATA, "/usr/bin/cvs @ARGV |" or die "Couldn't execute program: $! +";

I personally believe that even if probably it doesn't do any harm here, you should avoid naming your filheandle DATA since it's a predefined perl one. Of course, had you used a lexical instead, there would have been no problem a priori.

while ( defined( my $line = <DATA> ) ) {

As a side note: perhaps you know (and perhaps you don't know) that defined is pleonastic there since perl will dwimmily assume it implicitly for you.

chomp($line); print "$line\n"; } close DATA;

Sorry, but I'm very tired and I may be missing something obvious. Anyway: why are you doing this? Line ending conversion? Since it's the very last part of your script, you may even be thinking -for once- of using exec instead, couldn't you?

If you can't understand the incipit, then please check the IPB Campaign.

Replies are listed 'Best First'.
Re^2: cvs wrapper with ssh-agent
by jacques (Priest) on Sep 19, 2008 at 18:49 UTC
    Originally I had did not have the open() there and had the last line as:
    print `/usr/bin/cvs @ARGV`;
    But this failed when there were double quotes in the @ARGV. For example if @ARGV contained: commit -m "message goes here" filename_to_commit

    So I used open() instead.

      I personally believe

      If you use open or exec (or system) you can "bypass" the shell by passing a list with more than one element, e.g.:

      open my $data, '-|', '/usr/bin/cvs' => @ARGV or die horribly;
      If you can't understand the incipit, then please check the IPB Campaign.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://712568]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-10-30 17:29 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (282 votes). Check out past polls.