2 ms·
$ echo > /nonexistent-dir/filename zsh: no such file or directory: /nonexistent-dir/filename $ echo > /nonexistent-dir/filename bash: /nonexistent-dir/fi
by chrismorgan 5y ago
$ echo > /nonexistent-dir/filename
zsh: no such file or directory: /nonexistent-dir/filename
$ echo > /nonexistent-dir/filename
bash: /nonexistent-dir/filename: No such file or directory
In the middle of a shell script or makefile recipe, this can be hard to spot, and it may take a while to realise why it’s actually failing—that it’s the directory that doesn’t exist, not the file (which of course it doesn’t exist, you’re trying to create it!). I recently hit a messy race condition related to this: https://github.com/alexforster/libbpf-sys/commit/e65b4962e7de5fa0755b274d707d19c64c176913 https://github.com/alexforster/libbpf-sys/commit/e65b4962e7d... (described in the commit message).
I’ve been wondering about filing bugs against zsh and bash to be a little bit cleverer about their error message in this specific case, to only mention the nonexistent directory rather than the full path.