groff
[Top][All Lists]
Advanced

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

Re: [groff] 1.22.4.rc4 - Final RC before official 1.22.4


From: Ingo Schwarze
Subject: Re: [groff] 1.22.4.rc4 - Final RC before official 1.22.4
Date: Fri, 7 Dec 2018 19:22:42 +0100
User-agent: Mutt/1.8.0 (2017-02-23)

Hi Ralph,

Ralph Corderoy wrote on Fri, Dec 07, 2018 at 05:05:21PM +0000:
> Ingo:
>> Ralph:

>>> The time-honoured way to get modern-day `printf foo' is
>>> 
>>>     echo foo | tr -d \\012

>> Thanks for looking at it, but unfortunately, that does not work at all.
>> I just tested the version you suggest, and even on OpenBSD, it does not
>> work:
>>
>> .  pso sh -c \
>>        "printf '%s' '.ds *f ' ; \
>>         ls \\*[fontpath]/dev\*[.T] \
>>         | tr -d \\012"

> My pipeline was an example for sh(1);  its special characters need
> escaping if it's to undergo more levels of interpretation.  The `.pso'
> above keeps the printf when my point was to return to echo, and applies
> my suggested tr to ls's output, not echo's.

Why would you want to return to echo(1)?  POSIX requires printf(1),
using it is generally recommended in place of echo(1) because the latter
is awkward and riddled with portability issues, and i'm not aware
of printf(1) causing portability issues.  It works even on the
ancient Solaris 9.

> I was giving an equivalent to `printf foo'.  This deleting tr is not
> attempting to also do the work of any other tr that's transliterating to
> spaces.
> 
>     $ cat ingo.tr
>     .nf
>     .pl 3
>     .pso sh -c \
>        "echo foo \
>         | tr -d \\\\\\\\012 \

Aaaaaaaah!!!!!!!! ;-)

You know, around 1999-2002, i used to maintain this preprint server:

  https://www.ttp.kit.edu/en/publications/preprints

Back then, the escaping record in one of the Perl scripts used to
prepare submissions to TeXing was - eight successive backslashes.
I didn't hope that i might have to do such a thing again.

>         | od -c"
>     .bp
>     .pso sh -c " \
>       echo foo | \
>       tr -d '\\\\012' | \

OK, thanks for the cluestick.  With

        .  pso sh -c \
            "printf '%s' '.ds *f ' ; \
            ls \\*[fontpath]/dev\*[.T] \
            | tr -d '\\\\012'"

the substitution works, but of course no fonts are found.
Changing that to

        .  pso sh -c \
            "printf '%s' '.ds *f ' ; \
            ls \\*[fontpath]/dev\*[.T] \
            | tr '\\\\012' ' '"

makes everything work on OpenBSD.

Because i don't have the slightest idea what \012 might do under
EBCDIC or UTF-32 or any other exotic locale, i'd rather use \n,
which POSIX requires to be supported, instead of \012:

        .  pso sh -c \
            "printf '%s' '.ds *f ' ; \
            ls \\*[fontpath]/dev\*[.T] \
            | tr '\\\\n' ' '"

If people want that, i can commit the patch below, it works both
under OpenBSD, under Solaris 11, and under Solaris 9.

It's possibly even more portable than what we have now, and i don't
think not replacing other control characters is likely to cause trouble -
except that i'm not completely sure what "\n" does under Windows or
MacOS - how do the line endings emitted by ls(1) look like on those
systems?  Can anybody test on Windows, MacOS 9, and/or MacOS X?

Yours,
  Ingo


diff --git a/contrib/hdtbl/examples/fonts_n.in 
b/contrib/hdtbl/examples/fonts_n.in
index 72b5d2f3..6fcdcbf4 100644
--- a/contrib/hdtbl/examples/fonts_n.in
+++ b/contrib/hdtbl/examples/fonts_n.in
@@ -54,7 +54,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .  pso sh -c \
        "printf '%s' '.ds *f ' ; \
         ls \\*[fontpath]/dev\*[.T] \
-        | tr '[:cntrl:]' '[ *32]'"
+        | tr '\\\\n' ' '"
 .  \"  This dummy line is necessary; the preceding line eats it.
 .
 .  while !"\\*[*args]"" \{\
diff --git a/contrib/hdtbl/examples/fonts_x.in 
b/contrib/hdtbl/examples/fonts_x.in
index a4f2eab0..ba3cb37c 100644
--- a/contrib/hdtbl/examples/fonts_x.in
+++ b/contrib/hdtbl/examples/fonts_x.in
@@ -54,7 +54,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .  pso sh -c \
        "printf '%s' '.ds *f ' ; \
         ls \\*[fontpath]/dev\*[.T] \
-        | tr '[:cntrl:]' '[ *32]'"
+        | tr '\\\\n' ' '"
 .  \"  This dummy line is necessary; the preceding line eats it.
 .
 .  while !"\\*[*args]"" \{\



reply via email to

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