#942407 sponge: Non-existent directory only reported after usage

Package:
moreutils
Source:
moreutils
Description:
additional Unix utilities
Submitter:
Loren McIntyre
Date:
2019-10-15 19:57:04 UTC
Severity:
normal
#942407#5
Date:
2019-10-15 19:43:27 UTC
From:
To:
Dear Maintainer,

In normal usage of `sponge`, I expected behavior consistent with shell
redirection `>`, `mkdir`, and other tools.

I asked `sponge` to write to a file in a non-existent directory. It
failed to report a problem until exit, when it attempts to write the
file. This behavior hinders usability by failing to capture input as
expected.

On my debian machine at version 0.60-1 and on macOS brew-managed vresion
0.62, this usage resulted in an error reporting that the [(file or)
directory did not exist].

 `sponge` should error more eagerly, by checking for the existence of
 pre-requisite directories when it initially called.

 Best,
 Loren