[Top][All Lists]

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

Jitter portability improvements, poke updated

From: Luca Saiu
Subject: Jitter portability improvements, poke updated
Date: Sat, 16 May 2020 00:44:21 +0200
User-agent: Gnus (Gnus v5.13), GNU Emacs 27.0.50, x86_64-pc-linux-gnu


I improved Jitter's portability, particularly with respect to BSD
systems.  Thanks to Alfred M. Szmidt for bug reports and constructive
conversation during the debug phase.

Niobos might want to test the new version on his system.

New Jitter tag v0.9.216.  Updated poke submodule.

There remains a little bug I am too tired to fix now.  In case you are
curious about sed portability you can read on.  Alfred confirmed that
the behaviour is known; I very strongly dislike it, and now will be
forced to replace sed with something else in this situation.


The behavior of echo -n is portable to all the platforms I am mentioning
here; anyway I do not really use it in production.  It is just a way to
generate an input to be transformed.

My problem is the following:
  I want to replace the last character of each line, only when it is a '/',
  with a newline.

My solution, before the new bug I have just discovered, was using sed and then
tr in a pipe:

  echo -n '0/' | sed 's@/$@$@' | tr '$' '\n'

It is acceptable to have this special use for the '$' character in the
intermediate form.  This means that '$' will be forbidden in the actual input.

The tr part is not a problem.  The sed part is surprisingly tricky.

echo -n '0/' | sed 's@/$@$@'

This generates:
(two characters: zero, dollar, no newline) on GNU, OpenBSD, FreeBSD;

and, in escaped notation:
(three characters: zero, dollar, newline) on NetBSD.

In fact this NetBSD implementation of sed always outputs a trailing newline,
even when it performs no substitution:

  echo -n '0/' | sed 's@foo@bar@'
This generates
(three characters: zero, slash, newline).  Identical to the output of
  echo '0/' | sed 's@foo@bar@'
(with no -n), which is undistinguishable.

Incidantally I started using this replacement to avoid a limitation on
macos, where
  sed 's@anything$\n$@'
replaces 'anything' with a single
character -- which is documented behaviour.  GNU sed inserts a newline

Luca Saiu
* My personal web site:  http://ageinghacker.net
* GNU epsilon:           http://www.gnu.org/software/epsilon
* Jitter:                http://ageinghacker.net/projects/jitter

I support everyone's freedom of mocking any opinion or belief, no
matter how deeply held, with open disrespect and the same unrelented
enthusiasm of a toddler who has just learned the word "poo".

Attachment: signature.asc
Description: PGP signature

reply via email to

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