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

Re: Bug#270868: Should not implement "test" builtin



On Fri, 2004-09-10 at 15:43, Clint Adams wrote:
> If bash "echo", coreutils "echo", dash "echo", pdksh "echo", posh
> "echo", and zsh "echo" all behave differently, which shells are buggy?
> Which maintainer scripts are buggy for using "echo"?

Let's assume for the sake of argument that none of the shells is buggy
in relation to its own spec.  We'll also assume that "echo" behaves
differently in all those shells and in the standalong program.

Failure will occur if there is a script with "#!/bin/sh" that is written
on the assumption that "echo" works one way and the script is executed
under a shell whose "echo" behaves another way.

Where the bug lies depends on your perspective.  The script's author can
blame the administrator for pointing /bin/sh to the wrong shell.  The
administrator can blame the script author for not making his script
portable to the shell to which she has /bin/sh pointed.

The end result of such a situation would probably be that administrators
would always point /bin/sh at bash so that they wouldn't have to deal
with failing scripts.

Policy clause 10.4 is aimed at preventing that situation -- at
regulating scripts in such a way that it is possible for the
administrator to point /bin/sh at something faster than bash and thereby
to make some scripts run faster -- but its language isn't adequate to
the task.  It tells script authors to avoid writing scripts that use
"#!/bin/sh" and that use extra-POSIX features of shell builtins. 
However, "echo" isn't a shell builtin; therefore 10.4 doesn't restrict
how it can be used.

Now someone who hasn't read the whole thread is going to think that 10.4
should be extended to cover all POSIX utilities.  We can send that
person back to the beginning of the "Bug#267142: debian-policy: Sections
10.4 and 6.1 are inconsistent" thread where it is pointed out that this
measure would not suffice because shells can build in commands other
than ones mentioned by POSIX.

The latter is off topic for the "Bug#270868: Should not implement 'test'
builtin" thread.  The argument I made there is simply that posh is
enforcing the use of an impoverished "test" command for no good reason.

--
Thomas Hood



Reply to: