save --append: create file if it doesn't exist (#4156)

* have save --append create file if not exists

Currently, doing:

echo a | save --raw --append file.txt

will fail if file.txt does not exist. This PR changes that

* test that `save --append` will create new file
This commit is contained in:
Braulio Valdivielso Martínez
2021-11-26 18:27:41 +00:00
committed by GitHub
parent 91c270c14a
commit fb197f562a
2 changed files with 19 additions and 1 deletions

View File

@ -884,7 +884,7 @@ impl Shell for FilesystemShell {
) -> Result<OutputStream, ShellError> {
let mut options = OpenOptions::new();
if append {
options.append(true)
options.append(true).create(true)
} else {
options.write(true).create(true).truncate(true)
};