0
這裏是我的git push wordpress目錄的功能。如何在別名中設置函數參數?
pushwp(){
cd /var/www/html/wp
git init
git add *
git commit -am "$1"
git push -f origin master
}
pushwp函數處於良好狀態。
pushwp "it is a test"
Reinitialized existing Git repository in /var/www/html/wp/.git/
On branch master
nothing to commit, working directory clean
Everything up-to-date
現在分配帶有別名的函數。
alias pushme='pushwp(){
cd /var/www/html/wp
git init
git add *
git commit -am "$1"
git push -f origin master
}'
讓我們試試吧。
pushme "it is a test"
bash: syntax error near unexpected token `"it is a test"'
如何解決別名?
你已經有一個_function,_爲什麼地球上,你會包裝在一個別名?這個不成立!只需使用該功能。除非你想要一個_git alias._ –
你不需要。別名不是功能。 – melpomene
你的別名只*定義*的功能;它不會這麼稱呼它。你可以讓別名定義*和*調用函數('alias pushme ='pushwp(){...}; pushwp''),但是正如@gniourf_gniourf指出的那樣,很少或根本沒有理由這麼做。 – chepner