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-Injected-Via-Gmane: http://gmane.org/ To: cygwin AT cygwin DOT com From: Sam Steingold Subject: gdb passes different argv/argc to mingw & cygwin Date: 20 Jul 2003 20:20:47 -0400 Organization: disorganization Lines: 92 Message-ID: Reply-To: sds AT gnu DOT org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Complaints-To: usenet AT main DOT gmane DOT org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Note-from-DJ: This may be spam I observe some weirdness in argv/argc parsing in 1.3.22 (the current cygwin). Consider the attached C program and compile it with and without cygwin like this: $ gcc -Wall -g argtest.c -o argtest-cygwin $ gcc -Wall -g -mno-cygwin argtest.c -o argtest-mingw when passed arguments explicitly, they work reasonably (= like on linux) $ ./argtest-... "4 4" '5 5' * argc=3 [path/argtest-...] [4 4] [5 5] $ when called from a shell with the arguments in a variable, it is weird (same weirdness as on linux, so, I guess, I need to RTFM): arg='"4 4" '"'5 5'" ./argtest-... $arg * argc=5 [d:\sds\c\argtest-mingw.exe] ["4] [4"] ['5] [5'] (I expected the same output as with explicit args). Now the juice: when I run these under gdb, I get _different_ output with the same arguments: Starting program: /cygdrive/d/sds/c/argtest-mingw.exe arg 1 2 "3" "4 4" '5 5' * argc=8 [d:\sds\c\argtest-mingw.exe] [arg] [1] [2] [3] [4 4] ['5] [5'] Starting program: /cygdrive/d/sds/c/argtest-cygwin.exe arg 1 2 "3" "4 4" '5 5' * argc=7 [/cygdrive/d/sds/c/argtest-cygwin] [arg] [1] [2] [3] [4 4] [5 5] comments? -- Sam Steingold (http://www.podval.org/~sds) running w2k Those who can't write, write manuals. --=-=-= Content-Type: text/c Content-Disposition: attachment; filename=argtest.c Content-Description: C test program #include int main (int argc, char *argv[]) { printf(" * argc=%d\n",argc); while (argc--) printf("[%s]\n",*argv++); return 0; } --=-=-= Content-Type: text/sh Content-Disposition: attachment; filename=argtest Content-Description: shell script test #!/bin/sh args='"4 4" '"'5 5'" echo $args ./argtest-cygwin.exe ${args} ./argtest-mingw.exe ${args} --=-=-= Content-Type: text/plain; charset=us-ascii -- 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/ --=-=-=--