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

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

Date: Thu, 31 Oct 2024 08:59:47 -0300

To: Ralph Seichter, notmuch@notmuchmail.org

Cc: Ralph Seichter

From: David Bremner


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' ?

> +	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: