
我打算編寫一個 shell 腳本(如果需要具體信息,它將在 Zsh 中執行),它將通過運行確定最新的 Vim 補丁:
git pull origin master
vernew=$(git describe --tags | sed 's/^v//;s/-/./g')
使用 Vim git 存儲庫的本地副本,將其與我當前安裝的 Vim 版本進行比較,如果兩者不同,它將修改我在開放構建服務 (OBS) 中的規範文件中定義的補丁級別Vim 儲存庫。為了能夠做到這一點,我需要知道如何將變數定義為等於目前安裝的 Vim 版本。將其定義為:
verold=$(vim --version)
vim --version
至少對我來說,跑步不是一個選擇,回歸:
VIM - Vi IMproved 7.4 (2013 Aug 10)
Included patches: 1-1304
Compiled by 'http://www.opensuse.org/'
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +tag_binary
+arabic +file_in_path +mouse_sgr +tag_old_static
+autocmd +find_in_path -mouse_sysmouse -tag_any_white
-balloon_eval +float +mouse_urxvt -tcl
-browse +folding +mouse_xterm +terminfo
++builtin_terms -footer +multi_byte +termresponse
+byte_offset +fork() +multi_lang +textobjects
+channel +gettext -mzscheme +title
+cindent -hangul_input +netbeans_intg -toolbar
+clientserver +iconv +path_extra +user_commands
+clipboard +insert_expand +perl/dyn +vertsplit
+cmdline_compl +job +persistent_undo +virtualedit
+cmdline_hist +jumplist +postscript +visual
+cmdline_info +keymap +printer +visualextra
+comments +langmap +profile +viminfo
+conceal +libcall +python/dyn +vreplace
+cryptv +linebreak +python3/dyn +wildignore
+cscope +lispindent +quickfix +wildmenu
+cursorbind +listcmds +reltime +windows
+cursorshape +localmap +rightleft +writebackup
+dialog_con +lua/dyn +ruby/dyn +X11
+diff +menu +scrollbind +xfontset
+digraphs +mksession +signs -xim
-dnd +modify_fname +smartindent +xsmp_interact
-ebcdic +mouse +sniff +xterm_clipboard
+emacs_tags -mouseshape +startuptime -xterm_save
+eval +mouse_dec +statusline -xpm
+ex_extra -mouse_gpm -sun_workshop
+extra_search -mouse_jsbterm +syntax
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/current"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=1 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -Wall -pipe -fno-strict-aliasing
Linking: gcc -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.22.0/x86_64-linux-thread-multi/CORE -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXt -lX11 -lSM -lICE -lm -lnsl -ltinfo -lacl -lattr -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.22.0/x86_64-linux-thread-multi/CORE -L/usr/local/lib64 -fstack-protector-strong -L/usr/lib/perl5/5.22.0/x86_64-linux-thread-multi/CORE -lperl -lm -ldl -lcrypt -lpthread
該輸出的第二行包含我感興趣的內容,補丁層級。但我不知道如何定義verold
等於補丁等級。完整版本(即 7.4.1304)也是一個可接受的verold
值,如果您知道如何給我這個值。
答案1
verold=$(vim --version |sed -n 's/^Included patches:\s1-*//p')