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

From: "Arthur J. O'Dwyer" <ajo AT andrew DOT cmu DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bug in command-line globbing
Date: Thu, 12 Dec 2002 21:55:04 -0500 (EST)
Organization: Carnegie Mellon, Pittsburgh, PA
Lines: 100
Message-ID: <Pine.GSO.4.44L-027.0212122147030.22577-100000@unix14.andrew.cmu.edu>
NNTP-Posting-Host: smtp7.andrew.cmu.edu
Mime-Version: 1.0
X-Trace: bb3.andrew.cmu.edu 1039748103 28066 128.2.10.87 (13 Dec 2002 02:55:03 GMT)
X-Complaints-To: advisor AT andrew DOT cmu DOT edu
NNTP-Posting-Date: 13 Dec 2002 02:55:03 GMT
In-Reply-To: <Pine.GSO.4.44L-027.0212122038250.21386-100000@unix14.andrew.cmu.edu>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

[A. Sinan Unur wrote: something suggesting I clarify my question.]

On Thu, 12 Dec 2002, Arthur J. O'Dwyer wrote:
>
> % cat test.c
> #include <stdio.h>
>
> int main(int argc, char **argv)
> {
>     int i;
>     for (i=0; i < argc; i++) {
>         printf(":%s:\n", argv[i]);
>     }
>     return 0;
> }

This is the listing of a program written in C.

> % gcc -o test.exe test.c

This is the DOS command to compile the program using DJGPP.

> % test \

This is the invocation of the program with one argument.

> :\:

This is the output of the program with the invocation above.

> % test '\'
> :':
>
> % test '\\'
> :\':
>
> % test "\\"
> :\":

These are three more invocations and their outputs.

> %

This is the command prompt.

> So my question is: is this the correct behavior for the default
> "filename globbing" performed by DJGPP-compiled programs?

This is my question.

>                                                            If not,
> has it been reported before?

If this is not the correct behavior, then it is a bug and I should
report it to delorie.com.

>                               If so, why?

If this is the correct behavior, it looks to me like a design flaw.

> It looks like the '\' character escapes certain characters - quotes
> and double quotes, in particular - but does not escape itself.

This is my theory regarding what the globbing code is doing behind
the scenes.  'To escape' in this context means 'to strip of any special
meaning'.

>                                                                 This
> is probably a bug, and almost certainly a design flaw.

Self-explanatory, I hope.  This is a design flaw because it seems to
make the satisfaction of my request below ("The Request") impossible.

> If someone believes this is correct behavior, please tell me how to
> produce the output
>
> % test (something goes here)
> :*/:
> :hello:
>
> from the above program

This is "The Request".

>                        (assuming the program is called from a directory
> containing one or more subdirectories, of course).

If there are no subdirectories, it is trivial to satisfy The Request;
simply pass */ literally to the program, as:   % test */

> -Arthur,
> who wants to write a tr

This is my signature.  It explains that my reason for asking is because
I want to create a homemade version of the Unix utility 'tr'.  This
is irrelevant to the question (I know GNU makes a 'tr' already, and I
don't care).  That is why it is in my signature, as opposed to in the
message body.

- Raw text -


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