-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7306f0b
commit 5d4edf4
Showing
1 changed file
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,40 @@ | ||
#!/bin/bash | ||
# - written by @aonrjp | ||
|
||
TYPES=("houshin" "soukatsu") | ||
SECTIONS=("kaikei" "kensui" "soumu" "syogai" "system" "zentai") | ||
|
||
for type in ${TYPES[@]} | ||
for type in "${TYPES[@]}" | ||
do | ||
for section in ${SECTIONS[@]} | ||
# 各タイプ(houshin, soukatsu)のメインファイルを作成 | ||
main_file="src/${type}.tex" | ||
echo "\\documentclass{article}" > "$main_file" | ||
echo "\\begin{document}" >> "$main_file" | ||
|
||
for section in "${SECTIONS[@]}" | ||
do | ||
# 所定ディレクトリ以下に含まれるtexファイルを取得してソート | ||
files=`find src/${type}/${section} -type f -name "*.tex" | sort` | ||
files=$(find "src/${type}/${section}" -type f -name "*.tex" | sort) | ||
|
||
if [ "$1" = "show" ]; then | ||
# 見つかったtexファイルのパスを出力 | ||
echo "${files}" | ||
else | ||
# input文を生成 (シェルによって\\\\が\\となり、正規表現で\\は\を表す) | ||
doc=`echo "${files}" | sed -e 's/^/\\\\input{/' | sed -e 's/$/}/'` | ||
# セクションごとにサブセクションを作成 | ||
echo "\\section{${section^}}" >> "$main_file" | ||
|
||
# texファイルが発見できなければ虚無を | ||
if [[ $files == '' ]]; then | ||
doc='' | ||
# input文を生成し、メインファイルに追加 | ||
if [ -n "$files" ]; then | ||
while IFS= read -r file; do | ||
echo "\\input{${file}}" >> "$main_file" | ||
done <<< "$files" | ||
else | ||
echo "% No .tex files found in ${type}/${section}" >> "$main_file" | ||
fi | ||
|
||
# 書き込む | ||
echo "${doc}" > src/${type}/${section}.tex | ||
echo "" >> "$main_file" # 空行を追加 | ||
fi | ||
done | ||
|
||
# ドキュメントを閉じる | ||
echo "\\end{document}" >> "$main_file" | ||
done |