Closed chaifeng closed 4 years ago
And also, we can put CR in a string directly
for example, change the following code
header="\`CI Auto Message\`\n---\n"
to
header="CI Auto Message
"
We cannot use \n
everywhere, it depends on who uses it.
Should check the value of TRAVIS_PULL_REQUEST, it may be false.
Good catch @chaifeng ! I'll create a fix for this.
And also, we can put CR in a string directly
This contains the " ` " character which is used by markdown. I like the one-line solution better! :blush:
One-line solution:
header='`CI Auto Message`'$'\n'$'\n'"---"$'\n'
Use $'\n'
to replace c-style CR '\n'
, don't put $'\n'
in quotes.
Looks nice, I find the initial syntax more intuitive, even with escaped back-quotes. :laughing:
If you like the C-style syntax
printf -v header "\`CI Auto Message\`\n---\n"
Using printf
to save a C-style string to the variable header
, equals to:
header="\`CI Auto Message\`
---
"
But what's the difference between these two following? I mean they're the same, the first is just extra calling print -v
?
printf -v header "\`CI Auto Message\`\n---\n"`
to the initial:
header="\`CI Auto Message\`\n---\n"`
Yes, they are similar, what about this?
printf -v push_message '`%s`\n---\n%s\n%s' "$header" "$body" "$footer"
Pure. Implemented in #19.
https://github.com/mihaigalos/miniboot/blob/995c22f4e18acbf5417e3205a0f455f0134b3107/scripts/post_summary.sh#L14
Should check the value of
TRAVIS_PULL_REQUEST
, it may befalse
.Environment Variables - Travis CI