Re: [PATCH] gdb: check for empty strings in get_standard_cache_dir/get_standard_config_dir

Christian Biesinger via Gdb-patches
2021-01-08T11:06:01Z

On Thu, Jan 7, 2021 at 10:15 PM Simon Marchi via Gdb-patches
<gdb-patches@sourceware.org> wrote:
>
> On 2021-01-07 4:00 p.m., Tom Tromey wrote:
> >>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> >
> > Simon> gdb_abspath doesn't handle empty strings, so handle this case in the
> > Simon> callers. If a variable is defined but empty, I think it's reasonable in
> > Simon> this case to just ignore it, as if it was not defined.
> >
> > Makes sense to me.
> >
> > For XDG, I read here:
> >
> > https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
> >
> > this:
> >
> > All paths set in these environment variables must be absolute. If an
> > implementation encounters a relative path in any of these variables it
> > should consider the path invalid and ignore it.
> >
> > So I suppose we could go a bit further here.
> >
> > Tom
> >
>
> Ok, I can try this as a follow-up patch, check that the path
> is absolute using the IS_ABSOLUTE_PATH macro. Is a tilde path
> considered absolute? Like
>
> ~/my-cache
> ~smarchi/my-cache

IMO tildes in environment variables are pretty uncommon and often
unsupported by tools; usually the shell expands them before setting
it.

So I don't know if it's worth writing code to support that.

Christian