Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: eos.vss.fsi.com: ford owned process doing -bs Date: Tue, 9 Dec 2003 16:40:24 -0600 (CST) From: Brian Ford X-X-Sender: ford AT eos To: Luis Torres cc: "cygwin AT cygwin DOT com" Subject: Re: Different behaviour of "test -f" under cmd and bash, when called from compiled App In-Reply-To: <200312092230.hB9MUerM015044@mailgw01.flightsafety.com> Message-ID: References: <200312092230 DOT hB9MUerM015044 AT mailgw01 DOT flightsafety DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 9 Dec 2003, Luis Torres wrote: > 2) In relation to the above I tracked the following problem. If I use (interactive shell): > test -f AfileIKnowExists && echo YES (under either cmd.exe or Cygwin/bash), I get the correct answer > (test.exe from /cygdrive/c/cygwin/bin as per official distribution) > while if I use the code bellow within a program.exe compiled under Cygwin, I get the correct answer if > I use it within bash but NOT the correct answer if I use the program in cmd.exe > > Code : " > strcpy(command,"test -f "); > strcat(command,fpath); > if(verbose) > fprintf(stderr,"Executing %s\n", command); > if(!system(command)) > I don't see the problem right off, but HTH. This will do: /bin/sh -c command Also, sh is ash. With a command argument, the result of `system' is the exit status returned by `/bin/sh'. -- Brian Ford Senior Realtime Software Engineer VITAL - Visual Simulation Systems FlightSafety International Phone: 314-551-8460 Fax: 314-551-8444 -- 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/