www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/12/22:30:14

From: "A. Sinan Unur" <asu1 AT c-o-r-n-e-l-l DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bug in command-line globbing
Date: 13 Dec 2002 03:17:24 GMT
Organization: Cornell University
Lines: 85
Sender: asu1 AT cornell DOT invalid (on pool-141-149-207-54.syr.east.verizon.net)
Message-ID: <Xns92E2E2C07998Basu1cornelledu@132.236.56.8>
References: <Pine DOT GSO DOT 4 DOT 44L-027 DOT 0212122147030 DOT 22577-100000 AT unix14 DOT andrew DOT cmu DOT edu>
NNTP-Posting-Host: pool-141-149-207-54.syr.east.verizon.net
X-Trace: news01.cit.cornell.edu 1039749444 5503 141.149.207.54 (13 Dec 2002 03:17:24 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 13 Dec 2002 03:17:24 GMT
User-Agent: Xnews/5.04.25
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Arthur J. O'Dwyer" <ajo AT andrew DOT cmu DOT edu> wrote in news:Pine.GSO.4.44L-
027 DOT 0212122147030 DOT 22577-100000 AT unix14 DOT andrew DOT cmu DOT edu:

> 
> [A. Sinan Unur wrote: something suggesting I clarify my question.]
> 
> On Thu, 12 Dec 2002, Arthur J. O'Dwyer wrote:

<snipped a lot of obnoxious commentary>

C:\Dload\misc>cat arg.c
#include <stdio.h>

int main(int argc, char *argv[])
{
  if(argc > 1)
  {
    int i;
    for (i = 1; i < argc; ++i)
    {
      printf(":%s:\n", argv[i]);
    }
  }
  return 0;
}

C:\Dload\misc>gcc -Wall -pedantic arg.c -o arg.exe

C:\Dload\misc>arg "*/" hello
:*/:
:hello:

note that i starts from 1 in the for loop above to avoid printing the 
program name.

by the way, just reading the relevant sections of the FAQ (the beginning of 
which I pointed to in an earlier post in this thread) would have revealed 
this.

OTOH, if you want to write something like tr, then you might want to modify 
the program above:

C:\Dload\misc>cat arg.c
#include <stdio.h>

#ifdef __DJGPP__
/* The code below is from the FAQ as well:
   http://www.delorie.com/djgpp/v2faq/faq8_7.html
*/
#include <crt0.h>

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

#endif

int main(int argc, char *argv[])
{
  if(argc > 1)
  {
    int i;
    for (i = 1; i < argc; ++i)
    {
      printf(":%s:\n", argv[i]);
    }
  }
  return 0;
}

C:\Dload\misc>gcc -Wall -pedantic arg.c -o arg.exe

C:\Dload\misc>arg */ hello
:*/:
:hello:

Showing a little respect to people who are trying to help you is a 'good 
thing', even if you are a math major at CMU.

-- 
A. Sinan Unur
asu1 AT c-o-r-n-e-l-l DOT edu
Remove dashes for address
Spam bait: mailto:uce AT ftc DOT gov

- Raw text -


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