From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6593 invoked by alias); 16 Jul 2011 09:45:16 -0000 Received: (qmail 6583 invoked by uid 22791); 16 Jul 2011 09:45:14 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout22.012.net.il (HELO mtaout22.012.net.il) (80.179.55.172) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 16 Jul 2011 09:44:58 +0000 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LOF00200709PK00@a-mtaout22.012.net.il> for gdb-patches@sourceware.org; Sat, 16 Jul 2011 12:44:54 +0300 (IDT) Received: from HOME-C4E4A596F7 ([84.229.133.66]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LOF001HZ72R5LU0@a-mtaout22.012.net.il>; Sat, 16 Jul 2011 12:44:52 +0300 (IDT) Date: Sat, 16 Jul 2011 14:49:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH] gdb output pipelining to shell In-reply-to: To: Abhijit Halder Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <834o2my2uj.fsf@gnu.org> References: X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00412.txt.bz2 > Date: Sat, 16 Jul 2011 14:12:35 +0530 > From: Abhijit Halder > > I have implemented a feature which will allow one to pass the output > of any gdb command to the shell for further processing. Thanks. If this is accepted, we will need a corresponding addition to the manual. > + for (cpos = spos; (cpos = memchr (cpos, '"', (sh_cmd-cpos))) != NULL; cpos++) > + quote_cnt++; > + spos = (sh_cmd + 1); > + if ((quote_cnt % 2) == 0 || (sh_cmd = strchr (spos, '|')) == NULL) > + break; I'm not sure I understand this (comments would be helpful). Are you assuming that quote characters `"' in shell commands cannot be escaped, e.g. with a backslash? And what about quoting with a single quote character ("'")? > + if (*cpos != '{') > + return NULL; > + > + *cpos = ' '; > + > + cpos = epos; > + while (isspace(*cpos)) > + cpos--; > + > + if (*cpos != '}') > + return NULL; What is this magic about {...} that you are removing? Again, comments could help. > + > + *cpos = ' '; > + } > + > + if (sh_cmd) > + *sh_cmd++ = '\0'; > + > + return sh_cmd; This butchers the string passed to execute_command. Are you sure all the callers of execute_command can safely deal with that? What if the string is a constant string, for example?