delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/20/02:26:40

X-Spam-Check-By: sourceware.org
Message-ID: <46285D0C.F5C7BDD7@dessent.net>
Date: Thu, 19 Apr 2007 23:26:20 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: ImageMagick "display" and "convert" fail with a Visual C++ runtime error
References: <984298f00704192225n97bd4f0uc76ef0ce396c7cff AT mail DOT gmail DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Dmitry Golovaty wrote:

> Thanks - the culprit is the MATLAB entry
> 
> /cygdrive/c/Program Files/MATLAB/R2007a/bin/win32
> 
> in the path; removing it fixes the problem ... is there way to pluck
> it out automatically (e.g. in .bashrc) when the path is imported from
> Windows at Cygwin start-up? Thanks again and sorry for starting
> another thread - I did not subscribe in time to get the original
> message.

Interesting.

Well, there are a number of ways you could handle this.  The first one I
would try is just removing the offending directory from the PATH
alltogether and see if Matlab still works.  A lot of programs like to
add themselves to the PATH so that you can easily run them from a
Command Prompt but they still work fine without actually being in the
PATH if you launch them from a shortcut or whatnot.

If you just want to remove the entry in your shell startup files you
could try something like:

PATH=${PATH/\/cygdrive\/c\/Program Files\/MATLAB\/R2007a\/bin\/win32:/}

Advantages:

- uses a shell-builtin, so there's no overhead during shell startup for
having to run anything external

Disadvantages:

- very ugly on account of having to escape every / in the pattern.

- bash-specific, so it should only go in .bashrc, not rcfiles that might
be shared by other shells such as .profile or /etc/profile.

- won't work if the directory to be removed is the last in PATH, as it
requires matching the trailing ':' so as not to leave a "::" sequence
anywhere (which actually means "put . in the PATH" which you probably
don't want.)

An alternative would be something that uses a tool like sed, awk, or
perl to do the change, such as:

PATH=$(echo $PATH | perl -F: -lane \
   'print join(":",grep{!m,MATLAB/R2007a/bin/win32,i} @F)')

Advantages:

- should work with any shell

- directory to remove is a regular expression, so you can specify a
partial string to match, and use of ',' as delimiter means you don't
have to quote slashes

- splitting the PATH on ':' and treating it as a list means you don't
have to worry about matching ':'s or where in the string the directory
might occur

Disadvantages:

- Slower shell startup.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019