Subject: Re: [Bug-vc-dwim] bug#31368: vc-chlog reports "test: Illegal number" errors

From: Bruno Haible <[email-masked]>
Date: Sun, 06 May 2018 11:29:08 +0200

Hi Jim,

> I can make vc-chlog misbehave that way by configuring and building
> vc-dwim tools with an exuberant ctags binary first in search path, but
> (say later) running vc-chlog with a different ctags (e.g., from emacs)
> earlier in the search path.
> 
> You have two solutions:
> - rerun vc-dwim's configure+build+install to take into account the new
> ctags state of your shell's search path.
> - restore the expected ctags binary to the earlier spot in your
> shell's search path.

But I did not fiddle with PATH. I can reproduce the issue with
  $ cd vc-dwim-1.8
  $ ./configure --prefix=PREFIX    [the PREFIX/bin dir is in my $PATH]
  ...
  checking for ctags-exuberant... no
  checking for ctags... ctags
  checking whether ctags prints an extra column... no
  ...
  $ make
  $ make install
  $ cd ..
  $ wget -O gettext-clean.tar.xz 'https://www.dropbox.com/s/01pkbqsydi5ix0v/gettext-clean.tar.xz?dl=0'
  $ tar xf gettext-clean.tar.xz
  $ cd gettext-clean
  $ vc-chlog > /tmp/xx
  PREFIX/bin/vc-chlog: 459: test: Illegal number: +
  PREFIX/bin/vc-chlog: 458: test: Illegal number: +
  PREFIX/bin/vc-chlog: 474: test: Illegal number: +
  PREFIX/bin/vc-chlog: 459: test: Illegal number: gettext-runtime/m4/longlong.m4
  PREFIX/bin/vc-chlog: 458: test: Illegal number: gettext-runtime/m4/longlong.m4
  PREFIX/bin/vc-chlog: 474: test: Illegal number: gettext-runtime/m4/longlong.m4
  PREFIX/bin/vc-chlog: 483: test: Illegal number: /tmp/vcczGSIVa/oldfile-20-longlong.m4
  PREFIX/bin/vc-chlog: 482: test: Illegal number: /tmp/vcczGSIVa/oldfile-20-longlong.m4
  PREFIX/bin/vc-chlog: 498: test: Illegal number: /tmp/vcczGSIVa/oldfile-20-longlong.m4

The version of ctags that I have in $PATH is

  $ ctags --version
  ctags (GNU Emacs 23.1)
  Copyright (C) 2009 Free Software Foundation, Inc.
  This program is distributed under the terms in ETAGS.README

and I don't use ctags at all (there is no 'tags' or 'TAGS' file in the said
tarball).

> Ideas for how vc-dwim can do better on this front:
> - hard-code the path to ctags that it finds during configure, but we
> prefer not to hard-code such paths...
> - make vc-chlog detect which ctags it is using at run time. Not ideal,
> but it would have saved you this trouble. The configure check shows
> how simple the test is:
> 
> case `$CTAGS -x conftest.c` in
>   *function*) rw_cv_ctags_type_column=yes ;;
>   *) rw_cv_ctags_type_column=no;;
> esac

Hard-coding a path is not a good idea, I agree. As an administrator of my
machine, I hate it when GCC uses a hardwired 'as' or when autoconf uses a
hardwired 'm4' location.

This invocation is not very costly (4 ms in my case):
$ time ctags -x conftest.c
f                  2 conftest.c       f 

real    0m0.004s
user    0m0.000s
sys     0m0.000s

Therefore I would vote for moving this configure test to the run time.

Bruno