From d071b6cabd0fb92041a5424df0a7717177310399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Sat, 31 Oct 2020 18:10:12 +0100 Subject: [PATCH] Fix error reporting when EDITOR fails --- src/cli.cc | 2 +- t/opustags.t | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cli.cc b/src/cli.cc index 006bdb7..324729a 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -311,7 +311,7 @@ static ot::status edit_tags_interactively(ot::opus_tags& tags, const std::option fprintf(stderr, "warning: Leaving %s on the disk.\n", tags_path.c_str()); else remove(tags_path.c_str()); - return rc; + return editor_rc; } else if (!modified) { remove(tags_path.c_str()); fputs("Cancelling edition because the tags file was not modified.\n", stderr); diff --git a/t/opustags.t b/t/opustags.t index e1969a0..b34a3ae 100755 --- a/t/opustags.t +++ b/t/opustags.t @@ -4,7 +4,7 @@ use strict; use warnings; use utf8; -use Test::More tests => 45; +use Test::More tests => 47; use Digest::MD5; use File::Basename; @@ -226,7 +226,7 @@ unlink('out2.opus'); #################################################################################################### # Interactive edition -$ENV{EDITOR} = 'sed -i -e y/aeiou/AEIOU/'; +$ENV{EDITOR} = 'sed -i -e y/aeiou/AEIOU/ `sleep 0.1`'; is_deeply(opustags(qw(gobble.opus -o screaming.opus -e)), ['', '', 0], 'edit a file with EDITOR'); is(md5('screaming.opus'), '56e85ccaa83a13c15576d75bbd6d835f', 'the tags were modified'); @@ -234,6 +234,10 @@ $ENV{EDITOR} = 'true'; is_deeply(opustags(qw(-i screaming.opus -e)), ['', "Cancelling edition because the tags file was not modified.\n", 256], 'close -e without saving'); is(md5('screaming.opus'), '56e85ccaa83a13c15576d75bbd6d835f', 'the tags were not modified'); +$ENV{EDITOR} = 'false'; +is_deeply(opustags(qw(-i screaming.opus -e)), ['', "screaming.opus: error: Child process exited with 1\n", 256], 'editor exiting with an error'); +is(md5('screaming.opus'), '56e85ccaa83a13c15576d75bbd6d835f', 'the tags were not modified'); + unlink('screaming.opus'); ####################################################################################################