pcdshub / pcds-ci-helpers

Repository for continuous integration scripts - for PLC-related work and otherwise
3 stars 7 forks source link

REF: replace find-with-or with function #111

Closed klauer closed 1 year ago

klauer commented 1 year ago
#!/bin/bash

while IFS= read -r -d '' source_filename; do
    echo "Checking ${source_filename}"
done < <(find "." -type f -iname '*.TcDUT' -or -iname '*.TcGVL' -or -iname '*.TcPOU' -print0)
$ find . -name "*.Tc*" |wc -l
33
(^ this includes 3 TcTTO files we don't care about so our target is 30 files)
$ bash reproducing_gha.sh  |wc -l
19
$ bash pr.sh | wc -l
30

(If someone can clue me in what I'm doing wrong there - I'd certainly appreciate it...) In the meantime, the workaround in this PR seems to be fine as in the above file count listing.

tangkong commented 1 year ago

Apparently find with a command at the end only works on the last criterion unless you group the expression in \( \). This works for me:

#!/bin/bash

while IFS= read -r -d '' source_filename; do
    echo "Checking ${source_filename}"
done < <(find "." -type f \( -iname '*.TcDUT' -or -iname '*.TcGVL' -or -iname '*.TcPOU' \) -print0)

I won't take credit for this, stack exchange can

klauer commented 1 year ago

Well, I'll be... !

Regardless of where you got it, thanks for digging and figuring out the actual fix. Let me update this PR.