Skip to content

共有スクリプトのクォート修正 + shellcheck の CI 導入 - #178

Open
k-yoshimi wants to merge 3 commits into
developfrom
fix/172-quoting-shellcheck
Open

共有スクリプトのクォート修正 + shellcheck の CI 導入#178
k-yoshimi wants to merge 3 commits into
developfrom
fix/172-quoting-shellcheck

Conversation

@k-yoshimi

Copy link
Copy Markdown
Collaborator

概要

Fixes #172

util.sh の修正

  • check_cc/check_fc$@toupper/tolower/capitalizeecho $@is_macos のコマンド置換、find_tool の eval 部分をクォート
  • set_prefixMA_ROOT/BUILD_DIR/SOURCE_DIR に空白を含むパスを検出したら exit 127(全域が未クォート前提のため、暗黙の制約を明示的なエラーに)
  • calc_strip_components: grep $2 の無アンカー部分一致を grep -E "(^|/)$2\$" に(xREADME.mdREADME.md.bak への誤マッチを防止)
  • check_header: 存在しない cxx へのフォールバックを c++

その他のクォート修正

list_maversion.shfix_dylib.sh(1 行、#174 と軽微に競合する可能性あり→どちらを先にマージしても解消は自明です)、setup/config/default/setup.sh

CI

main.yml に shellcheck ジョブを追加(--severity=warning -s sh、対象は scripts/*.sh + setup/ + check_prefix.sh)。動的 source(SC1090/91)と local(SC3043)は設計上意図的なため .shellcheckrc で除外。apps/tools 配下への対象拡大は、触ったファイルから漸進的に行う想定です。

検証(macOS で実施)

  • shellcheck --severity=warning -s sh が対象全ファイルでクリーン、sh -n も全て通過
  • set_prefix + print_prefix が通常の設定で従来どおり動作
  • 空白入り MA_ROOTFatal: ... must not contain whitespace で exit 127(ディレクトリ未作成)になることを確認
  • calc_strip_components: pkg-1.0/README.md + 妨害ファイル(xREADME.md, NOTREADME.md.bak)入り tarball で正しく 1 を返す
  • find_tool zlib が実際のツール検出フロー(eval 書き換え箇所)で 1.2.12 を返す

🤖 Generated with Claude Code

- util.sh: quote "$@"/command substitutions (check_cc/check_fc args,
  toupper/tolower/capitalize, is_macos, find_tool), reject MA_ROOT/
  BUILD_DIR/SOURCE_DIR containing whitespace at set_prefix, anchor the
  filename match in calc_strip_components, and fall back to c++
  instead of the nonexistent cxx in check_header
- Quote remaining word-splitting hazards in list_maversion.sh,
  fix_dylib.sh, and setup/config/default/setup.sh
- Add a shellcheck job (severity=warning, -s sh) over the shared
  scripts, with SC1090/SC1091/SC3043 disabled via .shellcheckrc as
  intentional design choices

Fixes #172

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
k-yoshimi and others added 2 commits July 8, 2026 07:33
- Docs (how_to_use en/ja) and README now state that MA_ROOT/
  BUILD_DIR/SOURCE_DIR must not contain whitespace and how to work
  around a home directory that does
- reject_whitespace now tells the user where to fix the path
- Quote the util.sh source lines in check_prefix.sh and
  list_maversion.sh so a repo checkout path with spaces fails inside
  the guard rather than at the source statement

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@k-yoshimi

Copy link
Copy Markdown
Collaborator Author

AI review cycle (Codex + Antigravity) 結果

Phase 1 (Codex): must_fix 0 / should_fix 2 / optional 1。

  • check_headercxxc++check_cc/check_fc"$@" 化に互換性懸念の指摘 → 検証の結果、3 関数ともリポジトリ内に呼び出し元が存在しないことを確認(cxx は対象プラットフォームに存在せず旧フォールバックは機能し得なかった)。argv ベクタ渡しを今後の規約として受容。
  • "Failed: $*" の IFS 依存は「in-tree に IFS 変更なし」(レビュアー自身確認)のため受容。
  • 推奨テスト全実施: multi-arg の toupper 系、囮ファイル入り tarball での calc_strip_components、MA_ROOT/BUILD_DIR/SOURCE_DIR 各々の空白拒否、find_tool 実呼び出し、git diff --check、shellcheck。

Phase 2 (Antigravity): must_fix_docs 2 → 追加コミットで対応:

  • how_to_use (en/ja) と README に「パスに空白禁止」を明記
  • reject_whitespace のエラーに対処法(~/.mainstaller で設定)を追記
  • check_prefix.sh/list_maversion.sh の source 行と dirname "$0" をクォート(リポジトリ自体が空白パスにある場合の即死を防止)
  • shellcheck ジョブの並列配置は「app マトリクスをブロックしない現状が正しい」とのレビュアー評価どおり維持

Phase 1 再レビュー(エスカレーション): must_fix 0(optional の dirname クォートも適用済み)。

→ 両フェーズ収束。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] シェルスクリプト全般のクォート漏れと shellcheck の CI 導入

2 participants