Skip to content

Commit 27dbf14

Browse files
committed
fixed TOC insert on OSX, fixed #46
1 parent 1590bc1 commit 27dbf14

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gh-md-toc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,16 @@ gh_toc(){
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} "/${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 "/${ts}/r ${toc_path}" "$gh_src"
126+
if [[ "`uname`" == "Darwin" ]]; then
127+
sed -i "" "/${ts}/r ${toc_path}" "$gh_src"
128+
else
129+
sed -i "/${ts}/r ${toc_path}" "$gh_src"
130+
fi
127131
echo
128132
echo "!! TOC was added into: '$gh_src'"
129133
echo "!! Origin version of the file: '${gh_src}${ext}'"

0 commit comments

Comments
 (0)