Re: Emacs time stamp hook

2019-06-15 Thread Jim Meyering
Fine with me, too.


Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Paul Eggert

On 6/15/19 1:14 PM, Bruno Haible wrote:

I found that they got in the way of my understanding the code

Do you mean, we should highlight the comment about the program itself?


Partly that - the first comment of a script should be very brief 
(typically one line) and say what the script does; it shouldn't jump 
into gory implementation details. Your suggestion to use a followup 
comment with fancy highlighting characters is less useful to my eyes; 
I'm used to the more-standard convention of a short comment first.


But mostly because it's a big blob of text that just gets in the way of 
likely readers. A brief reference to perlrun will be better both for 
readers who already know this stuff (and don't need the details, just a 
reminder) and for readers who don't (for which the comment itself is a 
big and barely-understandable blob and will require reading perlrun and 
other stuff anyway). At least, that's how the comment strikes this 
particular reader.


But I won't fight about it.




Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Bruno Haible
Hi Paul,

> One quibble: those long comments are 
> probably more trouble than they're worth.

I heavily disagree: This piece of code needs to consider
  - the distinction between POSIX:2017 and earlier versions,
  - execlp/execvp vs. execl/execv,
  - GuixSD vs. traditional file system layouts,
  - perl documentation,
  - perl source code (toke.c).

> I suggest we just cite perlrun's man page

No, that man page represents only a small part of the entire picture.
Future maintainers should not have to wade through a mail thread of 12 mails
in order to understand a piece of code.

> I found that at least one important detail 
> was missing: the "#! -*-perl-*-" line is not just there for Emacs, but is 
> also 
> there for Perl.

Oh, indeed! So, both this line and the '-x' option are essential for perl.
I'm updating the comment:

--- a/build-aux/useless-if-before-free
+++ b/build-aux/useless-if-before-free
@@ -6,12 +6,12 @@
 # or execvp() fails with ENOEXEC if it is a script that does not start
 # with a #! line.  The script interpreter mentioned in the #! line has
 # to be /bin/sh, because on GuixSD systems that is the only program that
-# has a fixed file name.  The second line is for editing this file in
-# Emacs.  The next two lines below are valid code in both sh and perl.
-# When executed by sh, they re-execute the script through the perl
-# program found in $PATH.  The '-x' option is essential; without it,
-# perl would re-execute the script through /bin/sh.  When executed by
-# perl, the next two lines are a no-op.
+# has a fixed file name.  The second line is essential for perl and is
+# also useful for editing this file in Emacs.  The next two lines below
+# are valid code in both sh and perl.  When executed by sh, they re-execute
+# the script through the perl program found in $PATH.  The '-x' option
+# is essential as well; without it, perl would re-execute the script
+# through /bin/sh.  When executed by  perl, the next two lines are a no-op.
 eval 'exec perl -wSx "$0" "$@"'
  if 0;
 

> I found that they got in the way of my understanding the code

Do you mean, we should highlight the comment about the program itself?
Like this:

#!/bin/sh
#! -*-perl-*-
# This is a prologue that allows to run a perl script as an executable
# on systems that are compliant to a POSIX version before POSIX:2017.
# On such systems, the usual invocation of an executable through execlp()
# or execvp() fails with ENOEXEC if it is a script that does not start
# with a #! line.  The script interpreter mentioned in the #! line has
# to be /bin/sh, because on GuixSD systems that is the only program that
# has a fixed file name.  The second line is essential for perl and is
# also useful for editing this file in Emacs.  The next two lines below
# are valid code in both sh and perl.  When executed by sh, they re-execute
# the script through the perl program found in $PATH.  The '-x' option
# is essential as well; without it, perl would re-execute the script
# through /bin/sh.  When executed by  perl, the next two lines are a no-op.
eval 'exec perl -wSx "$0" "$@"'
 if 0;

# ╭───╮
# │ Detect instances of "if (p) free (p);".   │
# │ Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces. │
# ╰───╯

my $VERSION = '2018-03-07 03:47'; # UTC
...

Bruno




Re: Emacs time stamp hook

2019-06-15 Thread Bruno Haible
Paul Eggert wrote:
> I've never liked those timestamps, and would like to see them go away.

Fine with me: all of these files are in modules and therefore regularly
update through gnulib-tool.

Except for 'check-module', which is non-functional anyway for years
(since the introduction of conditional module dependencies); feel free
to do with 'check-module' as you like.

Bruno




Re: Emacs time stamp hook

2019-06-15 Thread Paul Eggert

Bruno Haible wrote:


However, for files that are only ever copied through gnulib-tool's module
system, I would not say that the time stamp is "really needed".


I've never liked those timestamps, and would like to see them go away. I often 
try to avoid updating them even when I edit the files with Emacs.




Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Paul Eggert
Thanks for looking into and fixing that. One quibble: those long comments are 
probably more trouble than they're worth. I found that they got in the way of my 
understanding the code, as my eyes glazed over when reading them. And when I 
finally forced myself to read one, I found that at least one important detail 
was missing: the "#! -*-perl-*-" line is not just there for Emacs, but is also 
there for Perl.


Instead of adding even more length to a comment that is already a bit of an 
obstacle to understanding the code, I suggest we just cite perlrun's man page as 
in the attached proposed patch. This should be good enough for anyone who's not 
already versed in perl+sh.
>From 7969fe73da89ac372c681dca7839b880b59767f1 Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Sat, 15 Jun 2019 11:27:52 -0700
Subject: [PATCH] Use shorter perlrun comment

* build-aux/announce-gen, build-aux/gitlog-to-changelog:
* build-aux/prefix-gnulib-mk, build-aux/update-copyright:
* build-aux/useless-if-before-free, tests/test-update-copyright.sh:
Just cite perlrun(1) in the comment.
---
 ChangeLog|  8 
 build-aux/announce-gen   | 13 +
 build-aux/gitlog-to-changelog| 13 +
 build-aux/prefix-gnulib-mk   | 13 +
 build-aux/update-copyright   | 13 +
 build-aux/useless-if-before-free | 13 +
 tests/test-update-copyright.sh   | 13 +
 7 files changed, 14 insertions(+), 72 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0d2f415f..77e66c0e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-15  Paul Eggert  
+
+	Use shorter perlrun comment
+	* build-aux/announce-gen, build-aux/gitlog-to-changelog:
+	* build-aux/prefix-gnulib-mk, build-aux/update-copyright:
+	* build-aux/useless-if-before-free, tests/test-update-copyright.sh:
+	Just cite perlrun(1) in the comment.
+
 2019-06-15  Bruno Haible  
 
 	Fix scripts to have valid executable format on Alpine Linux.
diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index b5728338c..1e2648d0e 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -1,17 +1,6 @@
 #!/bin/sh
 #! -*-perl-*-
-# This is a prologue that allows to run a perl script as an executable
-# on systems that are compliant to a POSIX version before POSIX:2017.
-# On such systems, the usual invocation of an executable through execlp()
-# or execvp() fails with ENOEXEC if it is a script that does not start
-# with a #! line.  The script interpreter mentioned in the #! line has
-# to be /bin/sh, because on GuixSD systems that is the only program that
-# has a fixed file name.  The second line is for editing this file in
-# Emacs.  The next two lines below are valid code in both sh and perl.
-# When executed by sh, they re-execute the script through the perl
-# program found in $PATH.  The '-x' option is essential; without it,
-# perl would re-execute the script through /bin/sh.  When executed by
-# perl, the next two lines are a no-op.
+# Either perl or sh can run this file; see perlrun(1).
 eval 'exec perl -wSx "$0" "$@"'
  if 0;
 
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index a616b8234..68722bacb 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -1,17 +1,6 @@
 #!/bin/sh
 #! -*-perl-*-
-# This is a prologue that allows to run a perl script as an executable
-# on systems that are compliant to a POSIX version before POSIX:2017.
-# On such systems, the usual invocation of an executable through execlp()
-# or execvp() fails with ENOEXEC if it is a script that does not start
-# with a #! line.  The script interpreter mentioned in the #! line has
-# to be /bin/sh, because on GuixSD systems that is the only program that
-# has a fixed file name.  The second line is for editing this file in
-# Emacs.  The next two lines below are valid code in both sh and perl.
-# When executed by sh, they re-execute the script through the perl
-# program found in $PATH.  The '-x' option is essential; without it,
-# perl would re-execute the script through /bin/sh.  When executed by
-# perl, the next two lines are a no-op.
+# Either perl or sh can run this file; see perlrun(1).
 eval 'exec perl -wSx "$0" "$@"'
  if 0;
 
diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk
index 66e138b46..10871a286 100755
--- a/build-aux/prefix-gnulib-mk
+++ b/build-aux/prefix-gnulib-mk
@@ -1,17 +1,6 @@
 #!/bin/sh
 #! -*-perl-*-
-# This is a prologue that allows to run a perl script as an executable
-# on systems that are compliant to a POSIX version before POSIX:2017.
-# On such systems, the usual invocation of an executable through execlp()
-# or execvp() fails with ENOEXEC if it is a script that does not start
-# with a #! line.  The script interpreter mentioned in the #! line has
-# to be /bin/sh, because on GuixSD systems that is the only program that
-# has a fixed file name.  The second line is for editing this 

Re: Emacs time stamp hook

2019-06-15 Thread Bruno Haible
Darshit Shah wrote:
> Do we really need these timestamp lines when everything is source-controlled
> using git?

They are useful in general for files that are not part of gnulib modules.
For example, in some project I was using a config.guess+config.sub combination
that was not updated in 8 years or so. The time stamp near the file header
made me aware of it.

However, for files that are only ever copied through gnulib-tool's module
system, I would not say that the time stamp is "really needed".

Bruno




socket module and sc_prohibit_always_true_header_tests

2019-06-15 Thread Tim Rühsen
Hi,

at GNU Wget we are currently a bit puzzled about gnulib-tool's pro-tip

#if HAVE_SYS_SOCKET_H
# include 
#elif HAVE_WS2TCPIP_H
# include 
#endif

and 'make syntax-check' complaining about using HAVE_SYS_SOCKET_H:

maint.mk: do not test the above HAVE__H symbol(s);
  with the corresponding gnulib module, they are always true
make: *** [maint.mk:825: sc_prohibit_always_true_header_tests] Fehler 1

So far we dealt with it by disabling
sc_prohibit_always_true_header_tests in cfg.mk, but it feels wrong and
we want to use that check general.

Other project suffer from this as well, e.g. GnuTLS
(https://gitlab.com/gnutls/gnutls/commit/a75d97033c839b0a764b50280b88b8fc6e4baa9f).

What is your advise ?

Regards, Tim



signature.asc
Description: OpenPGP digital signature


Re: Emacs time stamp hook

2019-06-15 Thread Darshit Shah
* Bruno Haible  [190615 14:02]:
> Hi Darshit,
> 
> > >  my $VERSION = '2018-03-07 03:46'; # UTC
> > 
> > Won't this break the emacs timestamp hook which apparently needs to be 
> > within
> > the first eight lines of the file? Maybe either reduce the text, or move the
> > hooks around.
> 
> In some files, such as gnulib.html in the web pages, the time stamp occurs 
> near
> the end of the file.
> 
> Also, build-aux/prefix-gnulib-mk has been manually modified 5 times by Jim
> and Paul, who surely are Emacs users, without the time stamp being bumped.
> To me, this indicates that the time stamp mechanism is not working anyway.
> 
> Can you please deal with this issue, i.e. make the time stamp mechanism
> work in the first place? I'm not a regular Emacs user.

I don't use emacs either. I just noticed that the comment below states that the
line **MUST** be within the first eight lines of the file. Assuming that this
was just a minor oversight, I reported it.

Do we really need these timestamp lines when everything is source-controlled
using git? Can we just remove it all?

-- 
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6


signature.asc
Description: PGP signature


Re: Emacs time stamp hook

2019-06-15 Thread Bruno Haible
Hi Darshit,

> >  my $VERSION = '2018-03-07 03:46'; # UTC
> 
> Won't this break the emacs timestamp hook which apparently needs to be within
> the first eight lines of the file? Maybe either reduce the text, or move the
> hooks around.

In some files, such as gnulib.html in the web pages, the time stamp occurs near
the end of the file.

Also, build-aux/prefix-gnulib-mk has been manually modified 5 times by Jim
and Paul, who surely are Emacs users, without the time stamp being bumped.
To me, this indicates that the time stamp mechanism is not working anyway.

Can you please deal with this issue, i.e. make the time stamp mechanism
work in the first place? I'm not a regular Emacs user.

Bruno




Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Darshit Shah
* Bruno Haible  [190615 13:07]:

> 2019-06-15  Bruno Haible  
> 
>   Fix scripts to have valid executable format on Alpine Linux.
>   Reported by Tim Rühsen .
>   Idea by Paul Eggert.
>   * build-aux/useless-if-before-free: Use a prologue that starts with
>   '#!/bin/sh'.
>   * build-aux/announce-gen: Likewise.
>   * build-aux/gitlog-to-changelog: Likewise.
>   * build-aux/prefix-gnulib-mk: Likewise.
>   * build-aux/update-copyright: Likewise.
>   * tests/test-update-copyright.sh: Update test program accordingly.
> 
> diff --git a/build-aux/announce-gen b/build-aux/announce-gen
> index 0174f5c..b572833 100755
> --- a/build-aux/announce-gen
> +++ b/build-aux/announce-gen
> @@ -1,6 +1,20 @@
> -eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
> -  & eval 'exec perl -wS "$0" $argv:q'
> -if 0;
> +#!/bin/sh
> +#! -*-perl-*-
> +# This is a prologue that allows to run a perl script as an executable
> +# on systems that are compliant to a POSIX version before POSIX:2017.
> +# On such systems, the usual invocation of an executable through execlp()
> +# or execvp() fails with ENOEXEC if it is a script that does not start
> +# with a #! line.  The script interpreter mentioned in the #! line has
> +# to be /bin/sh, because on GuixSD systems that is the only program that
> +# has a fixed file name.  The second line is for editing this file in
> +# Emacs.  The next two lines below are valid code in both sh and perl.
> +# When executed by sh, they re-execute the script through the perl
> +# program found in $PATH.  The '-x' option is essential; without it,
> +# perl would re-execute the script through /bin/sh.  When executed by
> +# perl, the next two lines are a no-op.
> +eval 'exec perl -wSx "$0" "$@"'
> + if 0;
> +
>  # Generate a release announcement message.
>  
>  my $VERSION = '2018-03-07 03:46'; # UTC

Won't this break the emacs timestamp hook which apparently needs to be within
the first eight lines of the file? Maybe either reduce the text, or move the
hooks around.


-- 
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6


signature.asc
Description: PGP signature


Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Bruno Haible
Paul Eggert wrote:
>  suggests something like the 
> following instead. This would avoid having separate shell scripts and .pl 
> files, 
> which would be a plus:
> 
> #!/bin/sh
> #! −*−perl−*−
> eval 'exec perl −x −wS $0 ${1+"$@"}'
>  if 0;

This does not work for me (with perl 5.22.1), unfortunately:

$ build-aux/useless-if-before-free
Can't open perl script "−x": No such file or directory

Ah, it's because it contains a non-ASCII '−' character! This one works:

#!/bin/sh
#! -*-perl-*-
eval 'exec perl -x -wS $0 ${1+"$@"}'
 if 0;

This one as well:

#!/bin/sh
#! -*-perl-*-
eval 'exec perl -wS -x $0 ${1+"$@"}'
 if 0;

Or this one:

#!/bin/sh
#! -*-perl-*-
eval 'exec perl -wSx $0 ${1+"$@"}'
 if 0;

${1+"$@"} is the same as "$@". Haven't seen a platform that needs
${1+"$@"} in 20 years. See also the discussion in

 .

And $0 needs to be double-quoted (in case the file name contains a space).

So, I'll use this prologue:

#!/bin/sh
#! -*-perl-*-
eval 'exec perl -wSx "$0" "$@"'
 if 0;


2019-06-15  Bruno Haible  

Fix scripts to have valid executable format on Alpine Linux.
Reported by Tim Rühsen .
Idea by Paul Eggert.
* build-aux/useless-if-before-free: Use a prologue that starts with
'#!/bin/sh'.
* build-aux/announce-gen: Likewise.
* build-aux/gitlog-to-changelog: Likewise.
* build-aux/prefix-gnulib-mk: Likewise.
* build-aux/update-copyright: Likewise.
* tests/test-update-copyright.sh: Update test program accordingly.

diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index 0174f5c..b572833 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -1,6 +1,20 @@
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
-  & eval 'exec perl -wS "$0" $argv:q'
-if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line.  The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name.  The second line is for editing this file in
+# Emacs.  The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH.  The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh.  When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
 # Generate a release announcement message.
 
 my $VERSION = '2018-03-07 03:46'; # UTC
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index deddef2..a616b82 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -1,6 +1,20 @@
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
-  & eval 'exec perl -wS "$0" $argv:q'
-if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line.  The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name.  The second line is for editing this file in
+# Emacs.  The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH.  The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh.  When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
 # Convert git log output to ChangeLog format.
 
 my $VERSION = '2018-03-07 03:47'; # UTC
diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk
index bef726f..66e138b 100755
--- a/build-aux/prefix-gnulib-mk
+++ b/build-aux/prefix-gnulib-mk
@@ -1,6 +1,19 @@
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
-  & eval 'exec perl -wS "$0" $argv:q'
-if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line.  The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file 

Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Bruno Haible
I wrote:
> So, the ENOEXEC error is a bug in musl. But POSIX does not specify that the
> command interpreter for scripts without shebang is /bin/sh; therefore IMHO
> it would be good not to make this assumption.

Correction:
 says
  "In the cases where the other members of the exec family of functions
   would fail and set errno to [ENOEXEC], the execlp() and execvp() functions
   shall execute a command interpreter and the environment of the executed
   command shall be as if the process invoked the sh utility using execl()
   as follows:

 execl(, arg0, file, arg1, ..., (char *)0);

   where  is an unspecified pathname for the sh utility ..."

So, the command interpreter must be sh-compatible; only its file name is
unspecified.

=> We need to change 'useless-if-before-free' not because of POSIX,
but only because of the musl bug and/or for systems that are compliant
with older versions of POSIX (older than POSIX:2017).

Bruno




Re: Alpine: useless-if-before-free: Exec format error

2019-06-15 Thread Paul Eggert

Bruno Haible wrote:

   - Add a shell script useless-if-before-free that merely does this:

  #!/bin/sh
  exec perl "$0".pl "$@"
 suggests something like the 
following instead. This would avoid having separate shell scripts and .pl files, 
which would be a plus:


#!/bin/sh
#! −*−perl−*−
eval 'exec perl −x −wS $0 ${1+"$@"}'
if 0;