Skip to content

Commit 85c95c7

Browse files
committedFeb 14, 2020
Update genarate-book.sh
* Use `find -print0` to handle filename contain whitespaces * Use symlink to miminal copies
1 parent bb5fc39 commit 85c95c7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
 

‎generate-book.sh

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
set -e
44

55
if [ ! -d src ]; then
66
mkdir src
77
fi
88

9-
echo "[Introduction](introduction.md)\n" > src/SUMMARY.md
9+
printf '[Introduction](introduction.md)\n\n' > src/SUMMARY.md
1010

11-
for f in $(ls text/* | sort)
11+
find ./text ! -type d -print0 | xargs -0 -I {} ln -frs {} -t src/
12+
13+
find ./text ! -type d -name '*.md' -print0 \
14+
| sort -z \
15+
| while read -r -d '' file;
1216
do
13-
echo "- [$(basename $f ".md")]($(basename $f))" >> src/SUMMARY.md
14-
cp $f src
15-
done
17+
printf -- '- [%s](%s)\n' "$(basename "$file" ".md")" "$(basename "$file")"
18+
done >> src/SUMMARY.md
1619

17-
cp README.md src/introduction.md
20+
ln -frs README.md src/introduction.md
1821

1922
mdbook build

0 commit comments

Comments
 (0)
Please sign in to comment.