On Sat, Dec 28, 2024 at 11:26 AM Simon Josefsson <si...@josefsson.org> wrote:
>
> Jim Meyering <j...@meyering.net> writes:
>
> > On Sat, Dec 28, 2024 at 10:01 AM Simon Josefsson <si...@josefsson.org> 
> > wrote:
> >> Jim Meyering <j...@meyering.net> writes:
> >>
> >> >> if test "x$v" = xUNKNOWN \
> >> >>         && test -f ${tarball_version_file}-git \
> >> >>         && head -1 ${tarball_version_file}-git \
> >> >>             | grep -v '^$Format' > /dev/null 2>&1; then
> >> >>     v=$(head -1 ${tarball_version_file}-git)
> >> >> fi
> >> >
> >> > That code uses "grep -v" where the intent must have been to use just 
> >> > "grep".
> >> > I've fixed that and cleaned up via this just-pushed change:
> >>
> >> Hi Jim.  Thanks for review!  No the intent is -v.  The export-subst
> >> logic is backwards.  The content of the file can only be used if it does
> >> NOT contain the '^$Format' keyword.  If the file contained that keyword,
> >
> > Sorry. I should have known.
> > How about this tiny adjustment, then?
> >
> > -    fmt=$(awk 'NR==1 && /^\$Format/ {print}' \
> > +    fmt=$(awk 'NR==1 && ! /^\$Format/ {print}' \
>
> That's fine with me, but now I did some testing... and on some platforms
> I got this because of awk vs gawk confusion:
>
> sh: awk: command not found
>
> This is used early in the ./configure loop, so using $AWK or adding some
> code to guess which awk to use seems a bit annoying.  Thoughts?

Thanks for testing. At first I thought, well, it'd be easy...

  AWK=${AWK:-awk}; (awk '{exit}' /dev/null) 2>/dev/null || AWK=gawk

At worst, resort to also testing for "mawk" in case some system still
has that yet neither awk nor gawk.
But you're right, this is getting too complicated.

We can make it simpler, avoiding both grep and awk:

  fmt=$(head -1 "${tarball_version_file}-git" 2>/dev/null)
  case $fmt in '$Format'*) ;; *) v=$fmt;; esac

Reply via email to