Skip to content

all.sh: improve fragile not grep idiom #266

@gilles-peskine-arm

Description

@gilles-peskine-arm

We often check for the absence of a function in a file with the idiom not grep REGEXP FILE[...] in all.sh. The function not is a wrapper around ! that takes care of failing the component if the command exits with the status 0. As noted in Mbed-TLS/mbedtls#10517 (comment) this is fragile: it'll pass if the file doesn't exist.

The goal of this issue is:

  1. Pick a name for a “not grep” function. not_grep is natural but might be a bit misleading since it's not just ! grep.
  2. Define a new function that does what we want. I believe the semantics is: not_grep REGEXP FILE[...] passes if all the files exist and the regexp is not found in any of the files. Note that the files can be expressed as a pattern, and since we use bash with default settings, if the pattern doesn't match any file, it'll remain unexpanded and the function will see it as a file name that doesn't exist.
  3. Systematically replace not grep by the new function in tests/scripts/components-*.sh in all branches.

Metadata

Metadata

Labels

enhancementNew feature or requestsize-xsEstimated task size: extra small (a few hours at most)

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions