Gary Johnson wrote:
> On 2021-03-25, Gary Johnson wrote: > > On 2021-03-25, Christian Brabandt wrote: > > > On Mi, 24 Mär 2021, Ron Aaron wrote: > > > > > > > I want to get the vim version for a bash script. The way I'm trying to > > > > use is: > > > > > > > > vim --not-a-term --cmd 'echo v:versionlong|quit' > > > > > > > > However, that spews a bunch of ANSI terminal control stuff as well, > > > > which I don't want. Is there an option to suppress that output? > > > > > > Have you tried TERM=dumb vim --cmd 'echo v:versionlong|quit'? > > > > I did. It eliminated all but t_cm and added a ^M. > > I think this is partly a bug in Vim. There are a few places in the > code where Vim assumes that it is running in a terminal as it > normally does and should output terminal control sequences without > regard to the presence of --not-a-term. > > I have attached a patch that seems to fix that problem. If someone > would rather I submitted a PR, I can do that, too. Since this is > just a proposal at this point, the patch was just easier for me. > > Even with the patch, though, I think using :echo to send something > to stdout is incorrect. The :echo command is intended to write to > the screen and does so under the control of Vim's screen management. > I think it would be a mistake to modify that code to have :echo > write to the screen or directly to stdout. I think a better > approach is to use echoraw() when you want to write directly to > stdout. > > That would change your command to this: > > vim --not-a-term --cmd 'call echoraw(v:versionlong)|quit' > > If you want to put a newline on the end of that, use this: > > vim --not-a-term --cmd 'call echoraw(v:versionlong."\n")|quit' > > Of course, neither of those will do what you want without my patch > applied. We'll have to see if Bram et al. think that's a good idea. Well, it's better than adding yet another command line argument. There is a tiny chance --not-a-term was only added to suppress the 2 second delay and still wanting to catch all the output. Let's see if anything has this problem. -- One difference between a man and a machine is that a machine is quiet when well oiled. /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202103271113.12RBDhKq564274%40masaka.moolenaar.net.
