Skip to content

Commit 1590bc1

Browse files
authored
Merge pull request #44 from chrisob/linux_fix
Fix sed syntax for Linux
2 parents 590e641 + 41236dc commit 1590bc1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

gh-md-toc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ gh_toc(){
110110
local toc=`gh_toc_md2html "$gh_src" | gh_toc_grab "$gh_src_copy"`
111111
echo "$toc"
112112
if [ "$need_replace" = "yes" ]; then
113-
local ts="\<\!--ts--\>"
114-
local te="\<\!--te--\>"
113+
local ts="<\!--ts-->"
114+
local te="<\!--te-->"
115115
local dt=`date +'%F_%H%M%S'`
116116
local ext=".orig.${dt}"
117117
local toc_path="${gh_src}.toc.${dt}"
118118
local toc_footer="<!-- Added by: `whoami`, at: `date --iso-8601='minutes'` -->"
119119
# http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
120120
# clear old TOC
121-
sed -i "${ext}" -e "/${ts}/,/${te}/ {//!d;}" "$gh_src"
121+
sed -i${ext} "/${ts}/,/${te}/{//!d}" "$gh_src"
122122
# create toc file
123123
echo "${toc}" > "${toc_path}"
124124
echo -e "\n${toc_footer}\n" >> "$toc_path"
125125
# insert toc file
126-
sed -i "" -e "/${ts}/r ${toc_path}" "$gh_src"
126+
sed -i "/${ts}/r ${toc_path}" "$gh_src"
127127
echo
128128
echo "!! TOC was added into: '$gh_src'"
129129
echo "!! Origin version of the file: '${gh_src}${ext}'"

0 commit comments

Comments
 (0)