Skip to content

GitVersion.sh: Make script simpler and more portable#416

Open
d97jro wants to merge 1 commit intoDrive-Trust-Alliance:masterfrom
d97jro:d97jro_shellfix
Open

GitVersion.sh: Make script simpler and more portable#416
d97jro wants to merge 1 commit intoDrive-Trust-Alliance:masterfrom
d97jro:d97jro_shellfix

Conversation

@d97jro
Copy link

@d97jro d97jro commented Dec 6, 2022

  • No need to use bash for simple script, more portable with /bin/sh when the content is POSIX anyway
  • Use command instead of which and string comparison to see if git executable exists
  • Do not double quote static strings
  • Use contemporary $() instead of deprecated backtick syntax

Signed-off-by: Joakim Roubert joakim.roubert@gmail.com

- No need to use bash for simple script, more portable with /bin/sh
  when the content is POSIX anyway
- Use command instead of which and string comparison to see if git
  executable exists
- Do not double quote static strings
- Use contemporary $() instead of deprecated backtick syntax

Signed-off-by: Joakim Roubert <joakim.roubert@gmail.com>
Copy link
Contributor

@scottcmarks scottcmarks left a comment

Choose a reason for hiding this comment

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

This results in a borked GIT_VERSION if git is installed but the sedutil-cli version is in fact downloaded from a tarball instead of being cloned. A more correct sh version would be something like this:

 "#define GIT_VERSION \"$(command -v git >/dev/null && git describe --dirty 2>/dev/null || echo tarball)\""

so that GIT_VERSION is defined to be tarball when git describe --dirty fails, which will happen if there is no .git subfolder because it was not cloned.

@scottcmarks scottcmarks self-assigned this Jun 16, 2025
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.

2 participants