[gccsdk] [Bug 237] New: Ampersands in command line arguments.

bugzilla-daemon at riscos.info bugzilla-daemon at riscos.info
Mon May 7 04:05:47 PDT 2012


           Summary: Ampersands in command line arguments.
           Product: GCC/GCCSDK
           Version: other
          Platform: Other
        OS/Version: RISC OS
            Status: NEW
          Severity: normal
          Priority: P1
         Component: C compiler
        AssignedTo: John.Tytgat at aaug.net
        ReportedBy: duncan_moore at ntlworld.com
   Estimated Hours: 0.0

GCCSDK GCC 4.1.2 Release 2 Development 2012-05-05

#include <stdio.h>
int main(int argc,char** argv) {
  while  (*++argv) printf("%s\n",*argv);
  return 0;

I've had trouble passing command line arguments with ampersands in them.
For example, I would expect:

*test &0 &0,&1 &9,&1 &-,&1 "&0,&1" &a,&b

but get:

*test &0 &0,&1 &9,&1 &-,&1 "&0,&1" &a,&b

(The argument in double quotes is missing completely.) The arguments seem to be
confused with redirection file descriptors, 2>&1 2>&- etc.

With just small changes to an argument, it can be quite unpredictable as to
what's going to be passed through. The only way I've found to get what I
originally wanted was to protect the first ampersand with both "" and \

*test "\&0,&1"

Configure bugmail: http://www.riscos.info/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.

More information about the gcc mailing list