我想管stderr
從gcc
到tee errors.err
,但我沒有運氣嘗試這兩塊我提出了:如何在vim中makeprg gcc pipe tee errors.err?
setlocal makeprg=gcc\ -Wall\ -Wextra\ -g\ -O0\ -ansi\ -pedantic-errors\ %\ -o\ %<.x\ 2>\ >(tee\ errors.err)
的文件是存在的,但它的空白。起初我以爲:make
正在刪除它,但即使使用set makeef=makeerrors.err
errors.err
文件仍然是空白。
其他(實際上是我以前的)解決方案是:
setlocal makeprg=gcc\ -Wall\ -Wextra\ -g\ -O0\ -ansi\ -pedantic-errors\ %\ -o\ %<.x\ 2>&1\ |\ tee\ errors.err
但我得到這個錯誤我從來沒有想出如何消除:E10: \ should be followed by /, ? or &
編輯1:我試過以便使用其他文件名,如teerrors.err
,以防萬一。同樣的問題。
編輯2:我也嘗試:
set shellredir=2>errorsredir.err
!gcc % -o %<.x
無濟於事。但是,無論如何,這不會是一個解決方案,因爲我不能將makeprg
設置爲過濾器。
編輯3:這一個(額外\
在管)
setlocal makeprg=gcc\ -Wall\ -Wextra\ -g\ -O0\ -ansi\ -pedantic-errors\ %\ -o\ %<.x\ 2>&1\ \|\ tee\ teeerrors.err
給出VIM錯誤:E492: Not an editor command: tee teeerrors.err
我剛用完的想法。
您可以放心地忘記'makeprg'。它被設計打破了,它永遠不會做你想要的。如果你使用'system()'和'cgetexpr',你可能會有更多的機會,只要你閱讀源代碼並找出正確的詮釋'shell','shellcmdflag','shellpipe','shellquote','shellredir ''''shellslash','shelltemp','shellxquote'和'shellxescape'。是的,這很糟糕。 – lcd047
謝謝。你的評論雖然沒有解決這個問題,但卻是一個不錯的靈感。我開始玩'makeprg = bash -c ...',只是爲了實現,由於錯誤消息,'makeprg'本身使用'bash -c ...'。所以我簡化了一些東西(見下面的答案)。 –