Colored shell commandline confuses ':make' ?

16 views
Skip to first unread message

tu...@posteo.de

unread,
Aug 18, 2017, 5:17:22 AM8/18/17
to vim...@googlegroups.com
Hi,

I ran into a problem and I dont know where to investigate first.
Since vim is the first instance, which uncovers the problem, I
will start asking here...

For my Arduino projects I want to get rid of the Ardyino IDE -- vim is the
better choice.

Here: https://github.com/sudar/Arduino-Makefile located is a Makefile
setup, which can be used to compile Arduino "sketches" into flashable
*.hex files.

I installed that and it works (beside some syntax errors I have to fix
-- mainly because previously the IDE has cheated one in thinking that
one writes "real C/++" by providing the prototypes of all functions
itsself.

But these kind of errors causes the problem now...

I start vim like this:

vim myfirmware.ino

vim starts and displays the contents of the ino-File.

The I type

: make

and hit return. vim jumps into the background and the bare
shell becomes visible.

The compilations starts and displays some errors -- missing
prototypes. But the output is colored by the shell.

After compilation ends, vim jumps into the foreground again,
displaying:
"^[[01m^[[Kmyfirmware.ino" [New File]
(45 of 75): ^[[m^[[K ^[[01;31m^[[Kerror: ^[[m^[[K'^[[01m^[[KdisplayTime^[[m^[[K' was not declared in this sc
ope

And BOOOM! my firmware.ino is no longer displayed. Instead I got a
new file which some really weird escape-sequences in its filename.

Which part of this "toolchain" is qyilty for that kind of rubbis? ;)

I am using:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Aug 18 2017 05:32:39)
Included patches: 1-956
Modified by Gentoo-9999
Compiled by mccramer@solfire
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
-balloon_eval +folding +mouse_xterm +termguicolors
-browse -footer +multi_byte +terminal
++builtin_terms +fork() +multi_lang +terminfo
+byte_offset +gettext -mzscheme +termresponse
+channel -hangul_input +netbeans_intg +textobjects
+cindent +iconv +num64 +timers
+clientserver +insert_expand +packages +title
+clipboard +job +path_extra -toolbar
+cmdline_compl +jumplist -perl +user_commands
+cmdline_hist +keymap +persistent_undo +vertsplit
+cmdline_info +lambda +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak -python +viminfo
-cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con +lua +rightleft +windows
+diff +menu -ruby +writebackup
+digraphs +mksession +scrollbind +X11
-dnd +modify_fname +signs +xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape +startuptime -xpm
+eval +mouse_dec +statusline +xsmp_interact
+ex_extra +mouse_gpm -sun_workshop +xterm_clipboard
+extra_search -mouse_jsbterm +syntax -xterm_save
+farsi +mouse_netterm +tag_binary
system vimrc file: "/etc/vim/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: x86_64-pc-linux-gnu-gcc -c -I. -Iproto -DHAVE_CONFIG_H -march=native -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: x86_64-pc-linux-gnu-gcc -Wl,-O1 -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -lncurses -lelf -lnsl -lacl -lattr -lgpm -ldl -L/usr/lib/x86_64-linux-gnu -lluajit-5.1


on Gentoo linux.

Thank you very much in advance for any help!
Cheers
Meino


Christian Brabandt

unread,
Aug 18, 2017, 5:36:20 AM8/18/17
to vim...@googlegroups.com
Yes, the makefile should only output ANSI color codes when it is
actually writing to the terminal. You would need to tell vim to strip
aways those ansi escape codes.

A quick google search, reveals how you can get rid of those chars:
https://unix.stackexchange.com/questions/4527

So something like this perhaps:

set makeprg=make\ \\\|\ sed\ -r\ "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"

Okay, quoting might become very ugly. You might want to create a
wrapperscript like this:

#!/bin/sh
make | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"

and use this for make like :set makeprg=my_make

However, I would still open a ticket at that repository and ask if there
is a way to build without outputting ansi escape codes

Best,
Christian
--
Wußten Sie schon...
... daß Haarspray gegen Glatzen überhaupt keine Wirkung zeigt, da aus
der Dose keine Haare herauskommen?

tu...@posteo.de

unread,
Aug 18, 2017, 5:51:24 AM8/18/17
to vim...@googlegroups.com
> --
> --
> You received this message from the "vim_use" 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_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Hi Christian,

Thanks for the hint where to start searching the culprit.
I fixed it myself -- the Arduino makefile defines -fdiagnostic-color
for gcc version > 490. I removed that option and now it works as
exspected.

I will open an issue on the github page next.

Thanks a lot for the support!
Cheers
Meino


Reply all
Reply to author
Forward
0 new messages