bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] texi2any: Don't switch to subdir mode if '-' exists


From: Patrice Dumas
Subject: Re: [PATCH] texi2any: Don't switch to subdir mode if '-' exists
Date: Wed, 8 Mar 2023 11:23:33 +0100

On Wed, Mar 08, 2023 at 11:01:33AM +0100, Arsen Arsenović wrote:
> * tp/texi2any.pl (output|out|o=s): If the filename argument is
> specifically '-', ignore a possible ./- subdirectory.  This
> prevents programs that generate info in a pipeline from being
> confused in weird working directories.

Looks good to me.  In the ChangeLog, "ignore a possible ./-
subdirectory." does not seem so clear to me.  I would prefer something
like "do not consider that it can be a directory, even if it exists as
a directory" or something like that, to be clearer that it is not
ignored, but considered as a file.

> ---
> Morning,
> 
> I was doing some math in Octave last night, and I typed in "help log",
> only to be met with a strange error:
> 
>   octave:2> help log
>   makeinfo: could not open -/octave-help-Q3PsCd.txt for writing: Permission 
> denied
>   makeinfo: could not open -/octave-help-Q3PsCd.txt for writing: Permission 
> denied
>   warning: help: Texinfo formatting filter exited abnormally; raw Texinfo 
> source of help text follows...
>   'log' is a built-in function from the file libinterp/corefcn/mappers.cc
> 
> This puzzled me for a bit, so I straced the makeinfo invocations Octave
> was making and found that makeinfo stats - in my home directory.
> 
> I was quite confused by having a ~/- owned by root, but, it was there,
> apparently.
> 
> The issue this introduced could be easily replicated as follows:
> 
>   ~$ mkdir --mode=000 ./-
>   ~$ makeinfo --output=- --plaintext /dev/null
>   makeinfo: could not open -/null.txt for writing: Permission denied
> 
> It is common practice to unconditionally interpret "-" as stdin despite
> an existing file, however, and this patch fixes that behavior up, and
> fixes Octave:
> 
>   ~$ mkdir --mode=000 ./-
>   ~$ ./gnu/texinfo/pre-inst-env octave --silent
>   octave:1> help log
>   'log' is a built-in function from the file libinterp/corefcn/mappers.cc
>   
>    -- log (X)
>        Compute the natural logarithm, ‘ln (X)’, for each element of X.
>   
>        To compute the matrix logarithm, see Linear Algebra.
>   
>        See also: exp, log1p, log2, log10, logspace.
> 
> OK for master?
> 
> Thanks in advance, have a lovely day.
> 
>  ChangeLog      | 8 ++++++++
>  tp/texi2any.pl | 2 +-
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 04d3020001..b3f69b6eec 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,11 @@
> +2023-03-08  Arsen Arsenović  <arsen@aarsen.me>
> +
> +     texi2any: Don't switch to subdir mode if '-' exists
> +     * tp/texi2any.pl (output|out|o=s): If the filename argument is
> +     specifically '-', ignore a possible ./- subdirectory.  This
> +     prevents programs that generate info in a pipeline from being
> +     confused in weird working directories.
> +
>  2023-03-07  Patrice Dumas  <pertusus@free.fr>
>  
>       * tp/Texinfo/Convert/HTML.pm (output_internal_links): determine if
> diff --git a/tp/texi2any.pl b/tp/texi2any.pl
> index 8d7af9554d..aad7ba4c3f 100755
> --- a/tp/texi2any.pl
> +++ b/tp/texi2any.pl
> @@ -1009,7 +1009,7 @@ There is NO WARRANTY, to the extent permitted by 
> law.\n"), "2022");
>                       $format = 'plaintext' if (!$_[1] and $format eq 
> 'info'); },
>   'output|out|o=s' => sub {
>      my $var = 'OUTFILE';
> -    if ($_[1] =~ m:/$: or -d $_[1]) {
> +    if ($_[1] ne '-' and ($_[1] =~ m:/$: or -d $_[1])) {
>        set_from_cmdline($var, undef);
>        $var = 'SUBDIR';
>      }
> -- 
> 2.39.2
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]