codesign -dv prints to stderr, so 'codesign -dv app | grep Signature' finds nothing
Seen on macOS 26.5, Xcode 26.4.1. codesign -dv file | grep -c Signature prints the full details (Executable=, Identifier=, CodeDirectory ... flags=, Signature=adhoc, TeamIdentifier=) on the terminal, but grep counts 0 lines and exits 1. The display output of codesign -d goes to stderr, not stdout, so the pipe receives nothing. A CI check like codesign -dv app | grep -q TeamIdentifier=ABC will always fail, and one using grep -v will always pass. Fix: redirect first, codesign -dv file 2>&1 | grep Signature, which printed Signature=adhoc. The exception is codesign -d --entitlements - file, where the entitlements data itself goes to stdout while the Executable= header still goes to stderr. codesign -v prints nothing on success and only signals through its exit status, so check that with if codesign -v file; then ... rather than by parsing output.