Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] fc -p allows invalid path without error
- X-seq: zsh-workers 53990
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: J R Becker <jrbecker002@xxxxxxxxxxxxxx>
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [BUG] fc -p allows invalid path without error
- Date: Tue, 14 Oct 2025 14:45:47 +0200
- Archived-at: <https://zsh.org/workers/53990>
- In-reply-to: <eYA5yyYaT75N9vHy8ie2uf--CS2cT7cxtM6Z1ab6BuLNU90phHZ0of_0ZxdZNhiRg2sQ-2x8aBYEFeLbACicoEz1h_GyOY6JYT8jv_T9-zI=@protonmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <eYA5yyYaT75N9vHy8ie2uf--CS2cT7cxtM6Z1ab6BuLNU90phHZ0of_0ZxdZNhiRg2sQ-2x8aBYEFeLbACicoEz1h_GyOY6JYT8jv_T9-zI=@protonmail.com>
On Mon, Oct 13, 2025 at 11:35 PM J R Becker <jrbecker002@xxxxxxxxxxxxxx> wrote:
>
> zsh 5.9 (x86_64-pc-linux-gnu)
>
> Expected behavior:
> Errors immediately.
> Actual behavior:
> No error until pop/write.
>
> % fc -p /nonexistent/path/file
> % fc -P
> 2: zsh: locking failed for /nonexistent/path/file: no such file or directory
>
> The absence of immediate path validation in fc -p seems atypical compared to the behavior of most Unix utilities, which generally report an error as soon as an invalid path is provided.
> Thank you to everyone on this list for your dedication to zsh and the collective effort that has kept it reliable and well-maintained; I hope this report contributes towards that reliability. I’d appreciate a quick reply to confirm whether this issue is of interest to the team.
History files are opened and written to only when you run fc -P (or
when running a command if you have incappendhistory or similar set),
so checking its existence when running fc -p would do nothing to
guarantee the open+write would be successful, these events could be
seconds or even months apart. Eg,
% fc -p /tmp/nonexistent/file
% fc -P
zsh: failed to write history file /tmp/nonexistent/file: no such file
or directory
% fc -p /tmp/nonexistent/file
% mkdir /tmp/nonexistent
% fc -P
% fc -p /tmp/nonexistent/file # imagine a successful check is done here
% rm -r /tmp/nonexistent
removed '/tmp/nonexistent/file'
removed directory '/tmp/nonexistent'
% fc -P # this must still fail
zsh: failed to write history file /tmp/nonexistent/file: no such file
or directory
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author