我正在编写一个脚本来为我的博客生成草稿。运行ShellCheck后,我不断看到此错误弹出。这是什么意思,有人可以提供一个例子吗?
SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects.
另外,我不确定我需要做什么才能将值传递给帖子的 YAML 中$title
的字段......"Title"
#!/bin/bash
# Set some variables
var site_path=~/Documents/Blog
drafts_path=~/Documents/Blog/_drafts
title="$title"
# Create the filename
title=$("$title" | "awk {print tolower($0)}")
filename="$title.markdown"
file_path="$drafts_path/$filename"
echo "File path: $file_path"
# Create the file, Add metadata fields
echo "---" > "$file_path"
{
echo "title: \"$title\""
} >> "$file_path"
echo "layout: post" >> "$file_path"
echo "tags: " >> "$file_path"
echo "---" >> "$file_path"
# Open the file in BBEdit
bbedit "$file_path"
exit 0