Adding PORTREVISION to a port that has none is currently broken: the check for $? currently retrieves the return value of the echo + awk call, which is not what we want. Instead, check for the return value of the grep call and set revision_num only if a PORTREVISION value has been found.
Details
- Reviewers
robak
./Tools/scripts/bump-revision.sh x11/libkonq works instead of throwing an error saying _ERROR: x11/libkonq PORTREVISION value is not a number, unable to solve!_.
Diff Detail
- Repository
- rP FreeBSD ports repository
- Lint
No Lint Coverage - Unit
No Test Coverage - Build Status
Buildable 2855 Build 2879: arc lint + arc unit
Event Timeline
Checking $? in a shell script is an anti-pattern, it should be more something like:
if grep -q "^PORTREVISION?\?=" "$1/Makefile then # do something if it is there else # do something else if not fi
And then, you can use set -e to fail on real errors and all.
What if you're also interested in grep's output? Can you do that without repeating the grep call? Also, would it be OK for you if this was done separately to keep the changes separate?
Let me review it, and I'll leave my comments - I was quite busy at the time when this revision was created, and afterwards I forgot about it.
Hey, your example works just fine for me, as it is:
[root@pd]❯❯❯ ./Tools/scripts/bump-revision.sh x11/libkonq INFO: x11/libkonq PORTREVISION= 1 found, bumping it by 1. [root@pd]❯❯❯
Can you reproduce it? Can you provide another example that you have failing?
For a reference, here's set of 'problematic' ports we've used in past to debug and test the code with:
[root@pd]❯❯❯ sh Tools/scripts/bump-revision.sh net/vmware-vsphere-cli security/p5-Net-SinFP accessibility/atk converters/ruby-iconv comms/concordance mail/opendkim INFO: net/vmware-vsphere-cli PORTREVISION= 3 found, bumping it by 1. ERROR: security/p5-Net-SinFP PORTREVISION found more than once, unable to bump it reliably! INFO: accessibility/atk PORTREVISION= 0 found, bumping it by 1. ERROR: converters/ruby-iconv might not be a port directory because converters/ruby-iconv/Makefile is missing! INFO: comms/concordance PORTREVISION= 1 found, bumping it by 1. INFO: mail/opendkim PORTREVISION= 5 found, bumping it by 1. [root@pd]❯❯❯
That's because x11/libkonq has had its PORTREVISION bumped since I posted this patch.
Try any port that has no PORTREVISION line, such as devel/zeal which I added today to the tree, and the bug still occurs.
/s/freebsd/ports-svn % /usr/ports/Tools/scripts/bump-revision.sh devel/zeal ERROR: devel/zeal PORTREVISION value is not a number, unable to solve!