在我的.bashrc
中,如果支持--color
選項,我想將grep別名爲grep --color
。但--color
不支持舊的系統,如msysgit:測試是否支持命令選項
$ grep --color
grep: unrecognized option '--color'
$ grep --version
grep (GNU grep) 2.4.2
在.bashrc中,我怎麼能確定選項是否被支持?我可以測試硬編碼的版本號,但將打破版本> 2.5:
if [[ `grep --version` == *2.5* ]] ; then
alias grep='grep --color=auto'
fi
有測試如果命令支持的選項更可靠的方法是什麼?
'grep(GNU grep)2.4.2版權所有2000自由軟件基金會公司'復古! –
MSys的開發人員熱衷於更新他們發佈的軟件包,但是它比您預期的要難得多https://github.com/msysgit/msysgit/issues/31 –