Re: [PATCH] Add support for ~/foo style relative paths

Subject: Re: [PATCH] Add support for ~/foo style relative paths

Date: Thu, 31 Oct 2024 15:42:10 +0200

To: notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


On Thu, Oct 31 2024, David Bremner wrote:

> Ralph Seichter <ralph@ml.seichter.de> writes:
>> +	 strcmp (key, "database.backup_path") == 0) {
>> +	if (val[0] == '~')
>> +	    /* Explicit syntax for "~/some/relative/path" */
>> +	    expanded_val = talloc_asprintf (ctx, "%s%s", getenv ("HOME"), &val[1]);
>
> what should we do if val[1] != '/'?  I think that is what derailed us
> last time. Do we think it's worth checking the passwd database for user
> names? what about things like '~.foo' ?

IMO:
	if (val[0] == '~' && val[1] == '/')

i.e. expand leading ~/ as $HOME/ -- otherwise expand as previously.

Tomi

>> +	else if (val[0] != '/')
>> +	    /* Implicit syntax for "some/relative/path" */
>> +	    expanded_val = talloc_asprintf (ctx, "%s/%s", getenv ("HOME"), val);
>> +    }
>> +    if (! expanded_val)
>> +	/* Catchall, no special expansion */
>>  	expanded_val = talloc_strdup (ctx, val);
>>  
>>      return expanded_val;
>
> If we do decide to make this change, obviously we'll need to update the
> documentation and (maybe less obviously) tests.
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: