我试图设置一个bash函数,以便我可以输入一些参数并创建一个git pull请求:
gpreq "<title>" "<ticketnumber>" "<release>" "<briefdescription>"
我已经尝试过这两个功能都无济于事:
gpreq () {
hub pull-request -m "$1\n\n Ticket: https://ticketsystem.net/issues/$2\n Target Release: $3\n Description: $4" ; }
以及
gpreq() {
STR="${1}"$'\n\n Ticket: https://ticketsystem.net/issues/'$"${2}"$'\n Target Release: '$"${3}"$'\n Description: '$"${4}"
hub pull-request -m "${STR}" ;
}
由于某些原因,换行似乎不起作用,而是\ n作为实际角色出现。任何帮助将不胜感激!
答案 0 :(得分:1)
(我不知道什么是中心)
\ n是由某些命令转换为换行符的字符。
尝试直接插入换行符
hub pull-request -m "$1
Ticket: https://ticketsystem.net/issues/$2
Target Release: $3
Description: $4"
或使用一些interpred \ n:
的函数STR="$1\n\n Ticket: https://ticketsystem.net/issues/$2\n Target Release: $3\n Description: $4"
STR
hub pull-request -m "`printf "${STR}"`"