Removed /usr/local from CDPATH
[clearscm.git] / lib / Clearcase.pm
index 651d33c..e34bf48 100644 (file)
@@ -80,7 +80,7 @@ use IPC::Open3;
 use OSDep;
 use Display;
 
-my ($clearpid, $clearin, $clearout, $oldHandler);
+my ($clearpid, $clearin, $clearout, $oldHandler, $cleartool);
 
 our $VIEW_DRIVE     = 'M';
 our $VOB_MOUNT      = 'vob';
@@ -150,7 +150,7 @@ sub DESTROY {
 
   # Call old signal handler (if any)
   &$oldHandler if $oldHandler;
-  
+
   return;
 } # DESTROY
 
@@ -523,7 +523,7 @@ sub execute {
 Sends a command to the cleartool coprocess. If not running a cleartool coprocess
 is started and managed. The coprocess is implemented as a coprocess using IPC
 for communication that will exist until the object is destroyed. Stdin and
-stdout/stderr are therefore pipes and can be fed. The execute method feds the
+stdout/stderr are therefore pipes and can be fed. The execute method feeds the
 input pipe and returns status and output from the output pipe.
 
 Using execute can speed up execution of repeative cleartool invocations
@@ -578,13 +578,13 @@ Array of output lines from the cleartool command execution.
   # installed under /opt/rational/clearcase/bin. This is needed in case we wish
   # to use these Clearcase objects say in a web page where the server is often
   # run as a plain user who does not have cleartool in their path.
-  my $cleartool;
-  
-  if ($ARCHITECTURE =~ /Win/ or $ARCHITECTURE eq 'cygwin') {
-    $cleartool = 'cleartool';
-  } elsif (-x '/opt/rational/clearcase/bin/cleartool') {
-    $cleartool = '/opt/rational/clearcase/bin/cleartool';
-  } # if
+  unless ($cleartool) {
+    if ($ARCHITECTURE =~ /Win/ or $ARCHITECTURE eq 'cygwin') {
+      $cleartool = 'cleartool';
+    } elsif (-x '/opt/rational/clearcase/bin/cleartool') {
+      $cleartool = '/opt/rational/clearcase/bin/cleartool';
+    } # if
+  } # unless
 
   # TODO: Need to catch SIGCHILD here in case the user does something like hit
   # Ctrl-C. Such an action may interrupt the underlying cleartool process and
@@ -593,10 +593,11 @@ Array of output lines from the cleartool command execution.
   if (!$clearpid) {
     # Simple check to see if we can execute cleartool
     @output = `$cleartool -ver 2>&1`;
-        
+    @output = ();
+
     return (-1, 'Clearcase not installed')
       unless $? == 0;
-          
+
     $clearpid = open3 ($clearin, $clearout, $clearout, $cleartool, "-status");
 
     return (-1, ('Clearcase not installed')) unless $clearpid;
@@ -630,7 +631,7 @@ Array of output lines from the cleartool command execution.
   $self->{lastcmd} = 'cleartool ' . $cmd;
   $self->{status}  = $status;
   $self->{output}  = join "\n", @output;
-  
+
   return ($status, @output);
 } # execute