Skip to content

Commit

Permalink
Make util/make_version more POSIX-compliant
Browse files Browse the repository at this point in the history
Fixes PrincetonUniversity#702

I've avoided `&>` as its not POSIX-complaint according to [stack
exchange](https://unix.stackexchange.com/a/590707/45323).

I've also taken the opportunity to simplify slightly the logic that
checks for `git`, relying on the return code of `command -v` rather than
testing that the resulting path exists.

Finally, I've removed the `2>/dev/null` redirect on `command -v`; when the
command does not exist, `command -v` is already silent, and I think we
want noise if `command` itself does not exist or is failing strangely
for some reason.
  • Loading branch information
JasonGross committed Aug 22, 2023
1 parent 2888663 commit c0c9b02
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions util/make_version
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env bash
#usage: util/make_version Bitsize Compcert-version
F=veric/version.v
builtin type -P gdate &> /dev/null
if [ $? -eq 0 ]; then
if command -v gdate >/dev/null; then
DATE=gdate
else
DATE=date
fi
set -e
printf >$F 'Require Import ZArith Coq.Strings.String. Open Scope string.\n'
printf >>$F 'Definition git_rev := "'
if [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
if command -v git >/dev/null && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
git log -n 1 --pretty=format:"%H" >>$F || true
fi
printf >>$F '".\n'
Expand Down

0 comments on commit c0c9b02

Please sign in to comment.