From 0bfac78f1ec6836d951c1e1bb962936e27923448 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 2 Mar 2017 18:29:42 -0500 Subject: [PATCH] CmdEdit: Properly captures an unmodified errno --- src/commands/CmdEdit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 0658284c0..748844ebd 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -770,13 +770,14 @@ ARE_THESE_REALLY_HARMFUL: // Launch the editor. std::cout << format (STRING_EDIT_LAUNCHING, editor) << '\n'; int exitcode = system (editor.c_str ()); + auto captured_errno = errno; if (0 == exitcode) std::cout << STRING_EDIT_COMPLETE << '\n'; else { std::cout << format (STRING_EDIT_FAILED, exitcode) << '\n'; if (-1 == exitcode) - std::cout << std::strerror (errno) << '\n'; + std::cout << std::strerror (captured_errno) << '\n'; return CmdEdit::editResult::error; }