tech-toolchain archive

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

Re: sh: utilities implemented as a built-in



    Date:        Thu, 23 Mar 2017 18:01:39 +0100
    From:        Edgar =?iso-8859-1?B?RnXf?= <ef%math.uni-bonn.de@localhost>
    Message-ID:  <20170323170138.GV13328%trav.math.uni-bonn.de@localhost>

  | Either I'm mis-understanding SUS or ash (and others) are not
  | POSIX-compliant.

You're not misreading it, and yes, almost no-one complies with that
section (which isn't there because of the original Bourne shell, which had
no normal utilities bult in, but ksh, upon which the POSIX shell spec
is based.)

It is very controversial.

For what it is worth, the way ash interpreted (an earlier version of)
that spec, is that it looks for a magic string '%builtin' in PATH (as
a component), and if it is found, it inserts all of its builtins at that
point in the path, so if you have PATH=/bin:%builtin:/other/stuff
then you will execute /bin/[ rather than the builtin '[' when the '['
command is encountered.

No-one should start using that "feature" - I expect it will be ripped
out of sh sometime - perhaps when there is some consensus as to what
POSIX really should say about this stuff (and incidentally, this is one area
where I don't actually agree that what it says is absurd, doing what it
actually mandates - what ksh (the real one, not our /bin/ksh) does - might
actually be entirely rational.

There's not currently any easy way to tell them difference (aside from
reading the standard, or the manual - looking top see what is documented
in sh(1) and what has a man page of its own) to tell the difference between
built-ins that must be built in, and ones that just are for effeciency.

But don't confuse the "special"  builtins with any of this, they're an
entirely different kettle of fish.

kre



Home | Main Index | Thread Index | Old Index