Mailinglist Archive: opensuse-factory (602 mails)

< Previous Next >
Re: [opensuse-factory] Can we assume that /bin/sh is bash?
  • From: Joerg Schilling <Joerg.Schilling@xxxxxxxxxxxxxxxxxxx>
  • Date: Mon, 11 Feb 2019 13:29:37 +0100
  • Message-id: <5c616ab1.4cnzYX3yvrQ3FX/l%Joerg.Schilling@fokus.fraunhofer.de>
Joerg Schilling <Joerg.Schilling@xxxxxxxxxxxxxxxxxxx> wrote:

This is a bash bug that has been fixed in bash-5.

Let me give some background information:

When David Korn introduced $(cmd) in ksh88, he thought that this could be
implemented with a simple parser that just counts brackets.

To permit this, he introduced the openning bracket: "switch ... case (x)"
but it turns out that there are many other cases in the shell command language
that need a recursive parser to support $(cmd), e.g. here documents that are
par of a $(cmd) construct.

Let me explain how bosh and mksh implement it:

- First the parser is called with the string similar to: "cmd)"
and told to stop parsing at a superfluous ")".

- The syntax tree that is the output from the parser is then
fed into the code that prints shell input from the binary tree (this
has been introduced for printing functions.

- This string is than kept in the syntax tree from the main parser call.

If you do it this way, there is no need to fail in the parser...

Jörg

--
EMail:joerg@xxxxxxxxxx (home) Jörg Schilling D-13353 Berlin
joerg.schilling@xxxxxxxxxxxxxxxxxxx (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >