Behavior of `:silent !{cmd}`

31 views
Skip to first unread message

Ken Takata

unread,
Feb 7, 2020, 4:19:53 AM2/7/20
to vim_dev
Hi,

`:help :!` says:

            Vim redraws the screen after the command is finished,
            because it may have printed any text.  This requires a
            hit-enter prompt, so that you can read any messages.
            To avoid this use: >
                :silent !{cmd}
<            The screen is not redrawn then, thus you have to use
            CTRL-L or ":redraw!" if the command did display
            something.

However, I think this is not accurate.

If 't_ti' and 't_te' are set to empty, then `:silent !{cmd}` keeps showing the
output of the command. User needs to use CTRL-L to show the Vim screen again.
(This behavior matches the help.)

On the other hand, if 't_ti' and 't_te' are set to default, Vim uses alternate
screen, then `:silent !{cmd}` shows a blank screen after the execution of the
command (even the command didn't display anything). User still needs to use
CTRL-L to show the Vim screen again.
This behavior differs from the help, and I don't think it is useful at all.
How about restoring the Vim screen automatically when alternate screen is
enabled? E.g.:

--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1469,6 +1469,8 @@ do_shell(
         wait_return(term_console ? -1 : msg_silent == 0); // see below
 # else
         wait_return(msg_silent == 0);
+        if (swapping_screen() && msg_silent > 0)
+            redraw_later_clear();
 # endif
         no_wait_return = save_nwr;
         }


The help should be also updated.

Regards,
Ken Takata

Ken Takata

unread,
Feb 7, 2020, 4:23:34 AM2/7/20
to vim_dev
Hi,
Hmm, it seems that Google Groups' Web interface automatically expands tabs into spaces.
I attached the correct patch.

Regards,
Ken Takata
silent-cmd.patch

Bram Moolenaar

unread,
Feb 7, 2020, 5:03:24 PM2/7/20
to vim...@googlegroups.com, Ken Takata
The problem appears to be that t_te includes ESC [J, which clears the
screen. When I remove the ":silent !ls" command is OK.

I wonder why it's in the default t_te entry. Can we just remove it?

--
Bumper sticker: Honk if you love peace and quiet.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Ken Takata

unread,
Feb 7, 2020, 5:18:58 PM2/7/20
to vim_dev
Hi Bram,
In my environment, t_te is "^[[?1049l^[[23;0;0t".
"^[[J" is not included.

Regards,
Ken Takata

Axel Bender

unread,
Nov 4, 2022, 5:44:17 AM11/4/22
to vim_dev
Was this issue ever resolved (I still observe it...)?

Bram Moolenaar

unread,
Nov 4, 2022, 3:49:01 PM11/4/22
to vim...@googlegroups.com, Axel Bender

> Was this issue ever resolved (I still observe it...)?

I do not think there is anything to resolve on the Vim side. You need
to check your setup for where the problem is coming from.
For me it works as the help says. If it works differently you must have
made some settings to make that happen. I can add tags for t_ti and
t_te in the help there, so the reader has a hint about alternatives.

>> > On the other hand, if 't_ti' and 't_te' are set to default, Vim uses
>> > alternate screen, then `:silent !{cmd}` shows a blank screen after
>> > the execution of the command (even the command didn't display
>> > anything). User still needs to

I don't know what "set to default" means here. I can only imagine
values coming from tercamp/terminfo, and that's a configuration thing,
not under control of Vim.

There were hints in previous message about what might be the problem for you.

>> > How about restoring the Vim screen automatically when alternate screen is
>> > enabled? E.g.:
>> >
>> > --- a/src/ex_cmds.c
>> > +++ b/src/ex_cmds.c
>> > @@ -1469,6 +1469,8 @@ do_shell(
>> > wait_return(term_console ? -1 : msg_silent == 0); // see below
>> > # else
>> > wait_return(msg_silent == 0);
>> > + if (swapping_screen() && msg_silent > 0)

There is no swapping_screen() function and I have no clue how to write
that. Parsing the termcap codes and guessing what they mean? Not a
good plan.


--
hundred-and-one symptoms of being an internet addict:
18. Your wife drapes a blond wig over your monitor to remind you of what she
looks like.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
Reply all
Reply to author
Forward
0 new messages