When I try to use a file name in a variable for the cs add command, I cannot understand what happens. I'm using a bash script myscript.sh which returns the path name of cscope database (/mydir/cscope.out) based on the current file name (/mydir/myfile.py):
:let db = system("myscript.sh " . expand("%:p"))
After that, when I call:
:cs add db
I get:
"E563: stat(/mydir/db) error 2"
When I call:
:exe "cs add " . db
I get:
"E563: stat(/mydir/cscope.out^@) error 2"
/mydir/cscope.out is the right file name which returned by myscript.sh, but where the ^@ thing comes from? How do I correctly use the variable with a parameter in this case?
P.S. When cs add is called with plain file name:
:cs add /mydir/cscope.out
Connection is created OK and no errors is reported.
:echo db
Displays:
/mydir/cscope.out
Press ENTER or type command to continue
^@is Ctrl-@, indicating the ASCII NUL character, which shouldn't be there sincesystemreplaces NULs with SOH (^A). – muru Dec 16 '15 at 12:46myscript.shincludes a new line character at the end of its output. ^@ is the caret notation of a null character (https://en.wikipedia.org/wiki/Null_character). You could try getting rid of it like this:let db=system("myscript.sh " . expand("%:p"))[:-2]orlet db=substitute(system("myscript.sh " . expand("%:p"), '\n$', '', '')orlet db=substitute(system("myscript.sh " . expand("%:p"), '[[:cntrl:]]', '', 'g'). Not tested so I don't know if any of these commands will work in your particular case. Found them here : http://superuser.com/a/935646 – saginaw Dec 16 '15 at 12:51