From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12182 invoked by alias); 17 Apr 2010 15:20:00 -0000 Received: (qmail 12173 invoked by uid 22791); 17 Apr 2010 15:19:59 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SARE_MSGID_LONG45 X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 17 Apr 2010 15:19:54 +0000 Received: by vws8 with SMTP id 8so1900490vws.0 for ; Sat, 17 Apr 2010 08:19:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.44.198 with HTTP; Sat, 17 Apr 2010 08:19:51 -0700 (PDT) In-Reply-To: <20100406215751.7EC1784397@ruffy.mtv.corp.google.com> References: <20100406215751.7EC1784397@ruffy.mtv.corp.google.com> Date: Sat, 17 Apr 2010 15:20:00 -0000 Received: by 10.220.123.104 with SMTP id o40mr1980696vcr.208.1271517592202; Sat, 17 Apr 2010 08:19:52 -0700 (PDT) Message-ID: Subject: Re: [RFA] Add -s option to source command. From: "H.J. Lu" To: Doug Evans Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2010-04/txt/msg00529.txt.bz2 On Tue, Apr 6, 2010 at 2:57 PM, Doug Evans wrote: > Hi. > > In a big source tree with multiple disparate components it's useful to be > able to load scripts without having to type full path names. > > This patch adds a -s option to the source command to make it search > for the script in the source search path even if the script name specifies > a directory. > For example, adding the top level source directory to the source search p= ath > lets one load scripts from any component by only typing the path from > the top directory. > > I thought of simply extending the source command to do the search anyway > but the current code explicitly doesn't do that to make "./foo" only mean > "foo" in the current directory. =A0Granted, the comment (see openp) is > referring to executables, but it's not clear to me it shouldn't also > apply to scripts. =A0Plus, "source /absolute/path" should probably not > scan the search path by default. > So I went with adding an option. > > This patch also does a minor reorg of find_and_open_script so that > it's useful in a subsequent patch I'll be submitting. > I think the reorg is useful in itself, e.g. removing the from_tty > arg to find_and_open_script, so I've including it here. > > Included are doc and testcase additions. > > Ok to check in? > > 2010-04-06 =A0Doug Evans =A0 > > =A0 =A0 =A0 =A0Add -s option to source command. > =A0 =A0 =A0 =A0* cli/cli-cmds.c (find_and_open_script): Add function comm= ent. > =A0 =A0 =A0 =A0Delete from_tty and cleanupp args. =A0Split filep arg into= file and > =A0 =A0 =A0 =A0full_pathp. =A0New arg search_path. > =A0 =A0 =A0 =A0(source_script_from_stream): New function. > =A0 =A0 =A0 =A0(source_script_with_search): New function. > =A0 =A0 =A0 =A0(source_script): Rewrite. > =A0 =A0 =A0 =A0(source_command): Parse "-s" option. > =A0 =A0 =A0 =A0(init_cli_cmds): Add "-s" docs to source command help. > =A0 =A0 =A0 =A0* python/python.c (source_python_script): Make file arg a = const char *. > =A0 =A0 =A0 =A0Don't call fclose, leave for caller. > =A0 =A0 =A0 =A0* python/python.h (source_python_script): Update. > > =A0 =A0 =A0 =A0testsuite/ > =A0 =A0 =A0 =A0* gdb.base/source-test.gdb: New file. > =A0 =A0 =A0 =A0* gdb.base/source.exp: Add tests for "source -v" and "sour= ce -s". > > =A0 =A0 =A0 =A0doc/ > =A0 =A0 =A0 =A0* gdb.texinfo (Command Files): Add docs for new "source -s= " option. > This caused: help source^M Read commands from a file named FILE.^M ^M Usage: source [-s] [-v] FILE^M -s: search for the script in the source search path,^M even if FILE contains directories.^M -v: each command in FILE is echoed as it is executed.^M ^M Note that the file ".gdbinit" is read automatically in this way^M when GDB is started.^M (gdb) FAIL: gdb.base/help.exp: help source --=20 H.J.