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

Build scripts: Use file name for grep directly #2397

Merged
merged 1 commit into from
Feb 20, 2022

Conversation

ann0see
Copy link
Member

@ann0see ann0see commented Feb 16, 2022

Short description of changes

Code Style: Do not use cat | grep due to performance reasons: https://bencane.com/2013/08/19/grepping-a-file-without-using-cat-and-grep-other-tricks/
Found by Codacy

Context: Fixes an issue?
No. Just code style

Does this change need documentation? What needs to be documented and how?

No
Status of this Pull Request

Waiting on CI

What is missing until this pull request can be merged?

Reviewing.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

Copy link
Member

@hoffie hoffie left a comment

Choose a reason for hiding this comment

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

Heh, micro-optimizations. :)

Meta: Both the PR title and the commit title could use some context in order for git log --oneline to be any useful. A shortened file name might do? build scripts: Use file name for grep directly

@ann0see ann0see force-pushed the feature/noUseCat branch 2 times, most recently from f895363 to d89e327 Compare February 18, 2022 12:57
@ann0see ann0see requested a review from hoffie February 18, 2022 12:59
@ann0see
Copy link
Member Author

ann0see commented Feb 18, 2022

Changed some more in mac/deploy_mac.sh and changed the commit name too

@ann0see ann0see changed the title Use file name for grep directly Build scripts: Use file name for grep directly Feb 18, 2022
Comment on lines +15 to +29
s)
cert_name=$OPTARG
if [[ -z "$cert_name" ]]; then
echo "Please add the name of the certificate to use: -s \"<name>\""
fi
# shift 2
;;
h)
echo "Usage: -s <cert name> for signing mac build"
exit 0
h)
echo "Usage: -s <cert name> for signing mac build"
exit 0
;;
*)
exit 1
;;

Copy link
Member

Choose a reason for hiding this comment

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

When working on style in this script anyway, then I'll add this here as well: ;)
I'd indent like described in this style guide (but with 4 spaces instead of 2, similar to what we do for if/while etc.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This means there will be some border cases this Python program won't be able to process. But in tests with large Linux system Bash scripts, its error-free score was ~99%.

Still sounds scary

Copy link
Member Author

Choose a reason for hiding this comment

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

Concerning indentation: I think this should be in #2402

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's now in the mentioned PR anyway (as own commit)

@ann0see
Copy link
Member Author

ann0see commented Feb 20, 2022

Should be merged after upcoming release

@ann0see ann0see merged commit e3a9bda into jamulussoftware:master Feb 20, 2022
@ann0see ann0see deleted the feature/noUseCat branch February 20, 2022 18:34
@hoffie hoffie mentioned this pull request Feb 21, 2022
5 tasks
@@ -73,7 +73,7 @@ build_installer_image()
local dmgbuild_bin="$(python -c 'import site; print(site.USER_BASE)')/bin/dmgbuild"

# Get Jamulus version
local app_version="$(cat "${project_path}" | sed -nE 's/^VERSION *= *(.*)$/\1/p')"
local app_version="$(grep -oP 'VERSION = \K\w[^\s\\]*' Jamulus.pro)"
Copy link
Member

Choose a reason for hiding this comment

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

This change from sed -nE to grep -oP breaks on Mac. See https://github.com/jamulussoftware/jamulus/runs/5247842643?check_suite_focus=true#step:6:1652

I've filed #2421 to fix this.

@hoffie
Copy link
Member

hoffie commented Feb 21, 2022

CHANGELOG: Build: Improve grep usage in scripts #2421
(The ID of this PR will be added automatically)

@pljones pljones added this to the Release 3.9.0 milestone Feb 21, 2022
@ann0see
Copy link
Member Author

ann0see commented Feb 21, 2022

Really sorry that you needed to fix my PRs @hoffie but thanks for finding the bugs.

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.

3 participants