Skip to content

Commit

Permalink
ビルドスクリプトの実行前後でシェルのモードに変更が入らないよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
abap34 committed May 21, 2024
1 parent 547da45 commit 40e986a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
# ワイルドカードが展開されるとカレントディレクトリのファイル名で展開されてマッチがおかしくなるので展開を抑制する.
# たとえばカレントディレクトリに `tmp.html` があると pettern が "tmp.html" と展開されてマッチしてしまうので抑制する必要がある。
# 今の set -f の状態を保存しておいて、最後に元に戻す
mode=$(set -o | grep noglob | awk '{print $2}')
set -f

src_dir="src/"
build_dir="build/"
Expand Down Expand Up @@ -37,17 +42,13 @@ mkdir -p "$build_dir"
cp -r "$src_dir" "$build_dir"


# ワイルドカードが展開されるとカレントディレクトリのファイル名で展開されてマッチがおかしくなるので展開を抑制する.
# たとえばカレントディレクトリに `tmp.html` があると pettern が "tmp.html" と展開されてマッチしてしまうので抑制する必要がある。
set -f

for file in $(find $build_dir -type f); do
vprint "----------------------------------------"
vprint "Check $file for data files"
for pettern in ${data_petterns[@]}; do
vprint " Check $pettern"
if [[ $file == $build_dir/*$pettern ]]; then
echo "$file is matching $pettern"
vprint "$file is matching $pettern"
echo "R\"(" > "$file.tmp"
cat "$file" >> "$file.tmp"
echo ")\"" >> "$file.tmp"
Expand All @@ -59,3 +60,11 @@ for file in $(find $build_dir -type f); do
vprint "$file is not matching any data file"
done


# 元に戻す
if [ $mode == "on" ]; then
set +f
fi


vprint "Finish setup."

0 comments on commit 40e986a

Please sign in to comment.