bug-texinfo
[Top][All Lists]
Advanced

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

Re: Fwd: REVIEW REQUEST - user manual generation


From: Vincent Belaïche
Subject: Re: Fwd: REVIEW REQUEST - user manual generation
Date: Sat, 04 Jun 2016 00:18:20 +0200

Hello,

Le 03/06/2016 à 18:15, Gavin Smith a écrit :
>> The problem is that my MSYS sed was version 3.02, and it did not
>> recognise \n in the replacement string when you want to make each funny
>> character on one line. I made some test with my git bash --- which has
>> sed version 4.2.1 --- and recognising \n is OK
>>
>
> Apparently it should be \NEWLINE, where NEWLINE is a newline
> character. Quoting is tricky, because \NEWLINE is interpreted as a
> line continuation except in single quotes or if the backslash is
> escaped. We are in single quotes, but those single quotes are within
> backquotes. I avoided this complication by using a function in the
> following patch:
>
> --- texi2dvi    (revision 7200)
> +++ texi2dvi    (working copy)
> @@ -918,6 +918,13 @@
>    fi
>  }
>
> +list_funnies ()
> +{
> +  echo "$in_input" \
> +    | $SED -e 's![^}#$%&^_{~]!!g' -e 's!\(.\)!\1\
> +!g' | uniq
> +}
> +

Just to say that I have tried the following both with sed 3.02 and sed
4.2.1:

--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
$ echo 'ab' | sed -e 's!\(.\)!\1\
> !g'
a
b
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

and it worked. So, your patch will make it.

Just as a minor comment, one could have the two instructions of the sed
script in the same -e argument provided that they are semi-colon
separated, like this:

--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
list_funnies ()
{
  echo "$in_input" \
    | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1\
!g' | uniq
}
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

This would be marginally more readable.

>  # run_tex - Run TeX as "$tex $in_input", taking care of errors and logs.
>  run_tex ()
>  {
> @@ -926,9 +933,8 @@
>    # Check for any unusual characters in the filename.
>    # However, >, \ and any whitespace characters are not supported
>    # filenames.
> -  in_input_funnies=`echo "$in_input" \
> -    | $SED -e 's![^}#$%&^_{~]!!g' -e 's!\(.\)!\1\n!g' \
> -    | uniq`
> +  in_input_funnies=`list_funnies`
> +
>    if test -n "$in_input_funnies" ; then
>      # Make > an end group character, as it's unlikely to appear in
>      # a filename.
>
>
>> Ok, one sh only solution would be to do this :
>>
>> --8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
>>   in_input_funnies=`echo "$in_input" \
>>     | $SED -e 's![^}#$%&^_{~]!!g' \
>>     | { while IFS= read -r -n1 -d '' c; do printf '%s\n' "$c"; done } \
>>     | uniq`
>> --8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----
>>
>> Hopefully this is portable code ;-) ...
>
> Options to "read" aren't portable AFAIK.

Thank you for clarifying the point. Anyway your solution is clearly
better.

VBR,
        Vincent.



reply via email to

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