2011-02-13 83 views
0

我正在寫一個bash腳本,其中包括觸發指定Drupal 6站點的代碼庫上的git提交。該腳本接受兩個參數,其中第二個參數是git commit的提交消息。通過參數傳遞字符串到bash腳本

#!/bin/sh 

directoryName=${1} 
commitMsg=${2} 

echo $directoryName 
echo $commitMsg 

git add . 
git commit -vam "The commit message" 

腳本被稱爲像這樣:

sh git-bash-test.sh name_of_directory "Custom commit message" 

我怎麼能變出的「提交信息」存儲在$ commitMsg價值?

+1

答案似乎太明顯是你真正要求; 「git commit -vam」$ {commitMsg}「」?我錯過了什麼嗎? – gamen 2011-02-13 14:27:01

回答

4

簡單地加上 「$ commitMsg」 替換爲:

git的承諾-vam 「$ commitMsg」

1
sh git-bash-test.sh name_of_directory "$commitMsg" 

請注意圍繞$commitMsg的雙引號。

相關問題