Bram,
I think ex_exitvalue needs to be reset after catching an exception.
Best,
Christian
--
Es wird Wagen geben, die von keinem Tier gezogen werden und mit
unglaublicher Gewalt daherfahren.
-- Leonardo da Vinci
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 2d9f8aab3573a01678130837659fdfa781cfba18 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Sun, 23 Oct 2016 13:53:30 +0200
Subject: [PATCH] Reset ex_exitvalue after catching an exception
fixes #1048
---
src/ex_docmd.c | 2 ++
src/testdir/test_alot.vim | 1 +
src/testdir/test_system.vim | 20 ++++++++++++++++++++
3 files changed, 23 insertions(+)
create mode 100644 src/testdir/test_system.vim
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 6802b8b..52140d6 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1419,6 +1419,8 @@ do_cmdline(
emsg(p);
vim_free(p);
}
+ /* emsg may set ex_exitval, reset here */
+ ex_exitval = 0;
vim_free(sourcing_name);
sourcing_name = saved_sourcing_name;
sourcing_lnum = saved_sourcing_lnum;
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
index d24b97f..54f8fb7 100644
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -36,6 +36,7 @@ source test_set.vim
source test_sort.vim
source test_statusline.vim
source test_syn_attr.vim
+source test_system.vim
source test_tabline.vim
source test_tabpage.vim
source test_tagcase.vim
diff --git a/src/testdir/test_system.vim b/src/testdir/test_system.vim
new file mode 100644
index 0000000..20c1104
--- /dev/null
+++ b/src/testdir/test_system.vim
@@ -0,0 +1,20 @@
+" Tests for system() function
+
+function! Test_system_exmode()
+ let cmd=" -es -u NONE -c 'try | call doesnotexist() | catch | endtry' +q; echo $?"
+ let a=system(v:progpath . cmd)
+ call assert_equal('0', a[0])
+ call assert_equal(0, v:shell_error)
+ let cmd=" -es -u NONE -c 'call doesnotexist()' +q; echo $?"
+ let a=system(v:progpath. cmd)
+ call assert_notequal(0, a[0])
+ let cmd=" -es -u NONE -c 'call doesnotexist()' +q"
+ let a=system(v:progpath. cmd)
+ call assert_notequal(0, v:shell_error)
+ let cmd=" -es -u NONE -c 'call doesnotexist()|let a=1' +q; echo $?"
+ let a=system(v:progpath. cmd)
+ call assert_notequal(0, a[0])
+ let cmd=" -es -u NONE -c 'call doesnotexist()|let a=1' +q"
+ let a=system(v:progpath. cmd)
+ call assert_notequal(0, v:shell_error)
+endfunc
--
2.9.3