Skip to content

fix: add bash-compatible short aliases to output.sh - #359

Merged
keito4 merged 2 commits into
mainfrom
fix/add-bash-aliases-to-output-lib
Jan 22, 2026
Merged

fix: add bash-compatible short aliases to output.sh#359
keito4 merged 2 commits into
mainfrom
fix/add-bash-aliases-to-output-lib

Conversation

@keito4

@keito4 keito4 commented Jan 22, 2026

Copy link
Copy Markdown
Owner

Summary

Add direct function aliases (info, success, warning, error, fatal) to support bash scripts that call these functions without the output:: namespace prefix.

Problem

The setup-team-protection.sh script was failing with "command not found" errors when calling info(), success(), warning(), and error() functions because:

  • script/lib/output.sh is a zsh script that defines functions with the output:: namespace prefix
  • Bash scripts like setup-team-protection.sh were calling these functions without the namespace prefix
  • The existing aliases in output.sh only worked for zsh, not bash

Solution

Add bash-compatible short aliases at the end of output.sh:

info() { output::info "$@"; }
success() { output::success "$@"; }
warning() { output::warning "$@"; }
error() { output::error "$@"; }
fatal() { output::fatal "$@"; }

These aliases ensure bash scripts can use the same simple function names without modification.

Testing

Tested with setup-team-protection.sh --dry-run - now successfully runs without "command not found" errors.

Impact

  • Fixes compatibility issues with bash scripts that source output.sh
  • No breaking changes to existing code
  • Both zsh and bash scripts can now use the library

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Five new shorthand functions added for message output (info, success, warning, error, fatal) to streamline command usage in scripts.

✏️ Tip: You can customize this high-level summary in your review settings.

github-actions Bot and others added 2 commits January 22, 2026 06:54
Retry semantic-release to create v1.52.0 release after v1.51.0 conflict.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add direct function aliases (info, success, warning, error, fatal) to
support bash scripts that call these functions without the output::
namespace prefix.

This fixes compatibility issues with bash scripts like
setup-team-protection.sh that were failing with 'command not found'
errors when calling info(), success(), etc.

The output.sh library is a zsh script but needs to support both zsh
and bash callers. These aliases ensure bash scripts can use the same
simple function names without modification.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size/XS PR サイズ Extra Small label Jan 22, 2026
@coderabbitai

coderabbitai Bot commented Jan 22, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Five new bash function aliases are added to script/lib/output.sh: info, success, warning, error, and fatal. Each forwards directly to its corresponding output:: function with argument preservation. No existing code is modified.

Changes

Cohort / File(s) Summary
Output convenience aliases
script/lib/output.sh
Added 5 new wrapper functions (info, success, warning, error, fatal) that forward to their respective output:: namespaced counterparts

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Five little shortcuts, so clean and neat,
Global aliases make output sweet,
No more output:: to type with care,
Just info, success, flying through the air! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding bash-compatible short aliases to output.sh. It is concise, specific, and clearly summarizes the primary purpose of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude

claude Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

PR Review: bash互換のショートエイリアス追加

✅ 総合評価

このPRは高品質であり、マージを推奨します。すべてのCIチェックが成功しており、明確な問題を解決する実用的な変更です。


📋 レビュー詳細

1. コード品質とベストプラクティス ✅

良い点:

  • 最小限の変更: 必要な5つの関数エイリアスのみを追加(script/lib/output.sh:152-156)
  • 一貫性: 既存の後方互換性エイリアスパターン(L122-149)と整合性あり
  • 明確なコメント: "Bash-compatible short aliases" という目的が明確
  • シンプルな実装: 各エイリアスが対応する output:: 関数を正しく呼び出し

コンテキスト:

  • zshスクリプト(#!/usr/bin/env zsh)がbashスクリプトから source される混在環境に対応
  • 25個のbashスクリプトと9個のzshスクリプトが存在する環境で重要な修正

2. 潜在的なバグや問題 ⚠️ (軽微)

名前空間の汚染リスク (低優先度):

  • グローバル関数名 info(), error() などは一般的な名前で、他のライブラリと競合する可能性があります
  • ただし、既存コードで print_error(), log_info() などのグローバルエイリアスも多数定義されているため、このリポジトリの既定パターンに従っています

推奨される緩和策 (任意):
将来的な改善案(このPRでは不要): スコープ制御が必要な場合は、スクリプト内で明示的に output:: を使用することを推奨

3. パフォーマンス ✅

影響なし:

  • 関数エイリアスは実行時オーバーヘッドが最小限
  • 1段階の間接参照のみ(info() → output::info())

4. セキュリティ ✅

現在の実装:

  • 資格情報スキャン通過(GitGuardian, Gitleaks: SUCCESS)
  • 依存関係レビュー通過
  • NPM監査通過

観察事項:

  • fatal() 関数はプロセスを終了するため、呼び出し元が適切なエラーハンドリングを実装することが重要です
  • 既存の実装は適切(set -euo pipefailと組み合わせて使用)

5. テストカバレッジ ⚠️ (改善余地あり)

現在の状況:

  • test/integration/lib_functions.bats に既存テストあり
  • 名前空間付き関数(output::info)とエイリアス(errors::info)のテストは存在

推奨される追加テスト:
test/integration/lib_functions.bats に bash互換性テストを追加推奨(このPRでは必須ではない)

理由:

  • 現在のテストはzshコンテキストで実行される可能性が高い
  • bash互換性の明示的な検証が有益

🔍 CLAUDE.md適合性チェック

2.3 Git Workflow ✅

  • ✅ Conventional Commits準拠
  • ✅ Diff 7行(≤ 400行制限)
  • ✅ ファイル数 1(≤ 25ファイル制限)
  • ✅ Co-Authored-By付き

2.2 Static Quality Gates ✅

  • ✅ Lint & Format: SUCCESS
  • ✅ Secret Detection: SUCCESS
  • ✅ License Compliance: SUCCESS
  • ✅ Integration Tests: SUCCESS

🎯 推奨事項

必須(マージ前): なし

このPRは現状のままマージ可能です

推奨(フォローアップ):

  1. テスト追加 (優先度: 低) - bash互換性の明示的な統合テストを追加
  2. ドキュメント更新 (優先度: 低) - script/lib/output.sh の冒頭コメントにbash互換性を明記

📊 まとめ

項目 評価 備考
コード品質 ⭐⭐⭐⭐⭐ シンプルで明確
バグリスク ⭐⭐⭐⭐☆ 軽微な名前空間懸念のみ
パフォーマンス ⭐⭐⭐⭐⭐ 影響なし
セキュリティ ⭐⭐⭐⭐⭐ 問題なし
テストカバレッジ ⭐⭐⭐⭐☆ 既存テストで基本的にカバー

最終推奨: ✅ 承認 & マージ推奨

この変更は実際の問題を解決し、既存のコードパターンに従い、すべての品質ゲートを通過しています。


🤖 レビュー実施: Claude Sonnet 4.5 via Claude Code
📋 CLAUDE.md準拠チェック完了

@keito4
keito4 merged commit 07dff36 into main Jan 22, 2026
16 checks passed
@keito4
keito4 deleted the fix/add-bash-aliases-to-output-lib branch January 29, 2026 00:52
keito4 pushed a commit that referenced this pull request Mar 15, 2026
cloud_provisioning PR #359 と同様に、ブランチ種別ごとのデフォルト保護を適用:
- main: enforce_admins=true, reviews=0, code_owner_reviews=false
- pre-production/production: enforce_admins=false, reviews=1, code_owner_reviews=true
--uniform オプションで従来の全ブランチ同一設定に切替可能

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS PR サイズ Extra Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant