Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with :P modifier when current directory is the root
- X-seq: zsh-workers 40831
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Bug with :P modifier when current directory is the root
- Date: Sat, 11 Mar 2017 08:47:45 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=vi62cXAi/MGCx/1 kGYz75Arax68=; b=MK6/aJ7Zkdj9WE4pcQfheKz+6fv8TvRSyLSKMw2neQ9IcdM DP9s6dNrLwU67YrjVYgEpAMdtCbE8GksPfX6yBRNa197ELkucb8KB4w0qO0E8Qzh 7OnZ3yzsfd7V1MPUH0Uo5vL1IwR2UYQLy8nZyyBgHAPF6d8BcTkzGYk+bh94=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=vi62cXAi/MGCx/ 1kGYz75Arax68=; b=aO84CLlmQZ34pzO0OtdaSEA8MDjjLaDItLfuMee/xWenLW 5aH4dmceCFUD4zy5cZTpOLFMSfCPwy69t23TROVSdreNOfNmfcopghIvbdi8xv4k lD6w0QX3qDnltVU/C9GkiJzaQYTnuV8Rnpu4dNu3c3KarO5723vP6zjdp4PEc=
- In-reply-to: <170310182501.ZM17524@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <170310182501.ZM17524@torch.brasslantern.com>
Bart Schaefer wrote on Fri, Mar 10, 2017 at 18:25:01 -0800:
> Does this need an extra test that (here[strlen(here)-1] != '/') or some
> such, or are we safe enough this way? Can zgetcwd() ever return "//" or
> "///" etc.?
zgetcwd() can return "." if the current working directory has been
deleted by another process.
I see zgetcwd() never returns NULL, but can it return an empty string?
> diff --git a/Src/subst.c b/Src/subst.c
> index 2214b3d..d68f16b 100644
> --- a/Src/subst.c
> +++ b/Src/subst.c
> @@ -4336,7 +4336,11 @@ modify(char **str, char **ptr)
> break;
> case 'P':
> if (*copy != '/') {
> - copy = zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP), "/", copy);
> + char *here = zgetcwd();
> + if (here[1])
> + copy = zhtricat(metafy(here, -1, META_HEAPDUP), "/", copy);
> + else
> + copy = dyncat(here, copy);
> }
> copy = xsymlink(copy, 1);
> break;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author