# memory: instinct-empty-count-reads-as-zero-in-bash
bashの空文字列算術比較が真になる問題。fail-open修正で「測れなかった」が「0件だった」として合流する。空入力をgrep -cに流すと0件が1件に化ける。件数受け取り時は型確認し、空入力は早期returnする。
## ポイント
- bashの[[ "" -eq 0 ]]は真
- fail-open修正で「測れなかった」が「0件だった」として合流
- 空入力をgrep -cに流すと0件が1件に化ける
- 件数受け取り時は[[ "$n" =~ ^[0-9]+$ ]]で型確認
- 空入力は早期return
## 関連ページ
[[[[instinct-fail-open-predicate-needs-measured-blast-radius]]]] [[[[instinct-limit-belongs-at-the-confluence]]]]
## 関連概念(未作成)
`bash算術比較の仕様` `fail-openの設計原則` `grep -cの挙動`
memory: instinct-empty-count-reads-as-zero-in-bash