This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/4] Introduce gdb_chdir
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb-patches at sourceware dot org, palves at redhat dot com
- Date: Wed, 13 Sep 2017 18:59:56 -0400
- Subject: Re: [PATCH 3/4] Introduce gdb_chdir
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=sergiodj at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE4C98553C
- References: <20170912042325.14927-1-sergiodj@redhat.com> <20170912042325.14927-4-sergiodj@redhat.com> <83h8w8q87m.fsf@gnu.org>
On Tuesday, September 12 2017, Eli Zaretskii wrote:
>> From: Sergio Durigan Junior <sergiodj@redhat.com>
>> Cc: Pedro Alves <palves@redhat.com>, Sergio Durigan Junior <sergiodj@redhat.com>
>> Date: Tue, 12 Sep 2017 00:23:24 -0400
>>
>> In order to be able to change the inferior's directory before its
>> execution, it is necessary to perform a tilde expansion of the
>> directory provided by the user and then chdir into the resulting dir.
>> This is what gdb_chdir does.
>>
>> Unfortunately it is not possible to use "tilde_expand" from readline
>> because this is common code and gdbserver doesn't use readline. For
>> that reason I decided to go with "glob" and its GNU extension,
>> GLOB_TILDE. With the import of the "glob" module from gnulib, this is
>> a no-brainer.
>
> Why not simply 'getenv("HOME")'?
Tilde expansion can be more complicated than that. If you're just using
"~/test", then yeah, you can use $HOME. However, the user can specify a
directory like "~someone/test", and in that case you have to where is
"someone's $HOME" before you can expand the tilde. glob takes care of
that for us.
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/