Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scripts/pre-commit #171

Merged
merged 1 commit into from
Aug 7, 2021
Merged

Fix scripts/pre-commit #171

merged 1 commit into from
Aug 7, 2021

Conversation

uta8a
Copy link
Contributor

@uta8a uta8a commented Aug 7, 2021

問題: pre-commitを設定して、clang-formatをかけるときに、for文の結果を渡しているため、

a.cpp # ok
b.cpp # ng
c.cpp # ok

のように最後がokで途中がngの順で検査すると、最後のokでExit code 0を受け取って HINT... 以降が働かなくなるのでcommitされてしまいます。

改善策: フォーマットすべきファイルが出たらそこで止めるようにしました。(ヒントを実行すれば一括でフォーマットされるのですべての警告を表示せず打ち切ってよさそうです。)

Copy link
Collaborator

@kmyk kmyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとう
set -e してるからこれでいい気がしてたけど、試してみるとたしかにだめですね

@kmyk kmyk merged commit d2be385 into kmyk-jikka:master Aug 7, 2021
@kmyk
Copy link
Collaborator

kmyk commented Aug 7, 2021

メモ:

$ bash -c 'set -ex; for i in 0 1 2; do [ $i -ne 0 ]; done || echo foo; echo bar'
+ for i in 0 1 2
+ '[' 0 -ne 0 ']'
+ for i in 0 1 2
+ '[' 1 -ne 0 ']'
+ for i in 0 1 2
+ '[' 2 -ne 0 ']'
+ echo bar
bar

$ bash -c 'set -ex; for i in 0 1 2; do [ $i -ne 0 ]; done; echo bar'
+ for i in 0 1 2
+ '[' 0 -ne 0 ']'

なんで? 後ろに || echo foo が付くか付かないかで for の中の挙動が変わるのはだめでしょ

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.

2 participants