Beginner scripting: ^@ appearing at the end of text

后端 未结 2 478
广开言路
广开言路 2020-12-19 19:10

I\'m trying to create a script that helps creating shebangs (Ok, it may not be that useful but has advantages when you don\'t know where the program is, for example), here\'

2条回答
  •  执笔经年
    2020-12-19 19:25

    Probably the which command output contains the NULL character.

    The system() function replaces line breaks with s. (from :help system()). Therefore you could do:

    let path = substitute(system('which ' . program), '\%x00', '', 'g')
    

    Otherwise you could do the following:

    function! CreateShebang()
        call inputsave()
        0 put = '#!/usr/bin/env ' . input('Enter the program name: ')
        call inputrestore()
    endfunction
    

提交回复
热议问题