If you press the message given by shellcheck, you will arrive at https://github.com/koalaman/shellcheck/wiki/SC2129
Here you can find the following:
Problem code:
echo foo >> file date >> file cat stuff >> file
The correct code is:
{ echo foo date cat stuff } >> file
Justification:
Instead of adding → something after each line, you can simply group the appropriate commands and redirect the group.
Exceptions
This is basically a stylistic issue and can be freely ignored.
So basically replace:
echo "---" > "$file_path" { echo "title: \"$title\"" } >> "$file_path" echo "layout: post" >> "$file_path" echo "tags: " >> "$file_path" echo "---" >> "$file_path"
WITH
{ echo "---" echo "title: \"$title\"" echo "layout: post" echo "tags: " echo "---" } > "$file_path"
Even if I suggested you use heredoc :
cat >"$file_path" <<EOL --- title: "$title" layout: post tags: --- EOL
source share