delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/15/21:58:04

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Command line parameters
Date: Wed, 15 Sep 1999 13:18:35 -0700
Organization: Harvey Mudd College
Lines: 44
Message-ID: <37DFFF1B.C542F0D3@hmc.edu>
References: <37DFDE6C DOT CF7B3B8B AT netvigator DOT com>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 937426702 36229 134.173.45.219 (15 Sep 1999 20:18:22 GMT)
X-Complaints-To: usenet AT nntp1 DOT interworld DOT net
NNTP-Posting-Date: 15 Sep 1999 20:18:22 GMT
X-Mailer: Mozilla 4.61 [en] (X11; U; Linux 2.2.13pre7 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"NG Chi Fai, John" wrote:
> 
> Hello all,
> 
> I have a program that take command line parameters.
> 
> int main(int argc, char * argv) { }
> 
> When I put ".\somedir\*.*" as the parameter, argc is not 2, but can be
> anything, say, 3 if I have 3 files in the "somedir", and the parameters
> will be:
> 
> .\somedir\file1.sth
> .\somedir\file2.sth
> .\somedir\file3.sth
> 
> I think it is a little bit weird.
> 
> I'm using DJGPP with EGCS.
> 
> Please advise how anything I can do such that I only receive 1
> paramenter ".\somedir\*.*"
> 
> Thanks in advance.
> 
> NG Chi Fai

Quote it.  i.e. run the program like

foo ".\somedir\*.*"

This is a feature; it's so Unix ports can do things like "rm *" even
without a Unixy shell installed.

You can also disable globbing (that's what this expansion is called) by
defining a function like

char **__crt0_glob_function (char *arg) { return 0; }

in your source.
-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


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