just another one of my rumblings

Paul Smith paul at mad-scientist.us
Fri Apr 25 19:49:11 UTC 2008


On Fri, 2008-04-25 at 21:24 +0200, Denys Vlasenko wrote:
> On Friday 25 April 2008 21:13, Cristian Ionescu-Idbohrn wrote:
> > Please consider the attached patch, which eliminates the use of
> > 'basename' and 'dirname'.

Just a note: although ash does support it, "local" is not a POSIX shell
feature and "local" is not a reserved word in the POSIX shell, nor even
a suggested reserved word.

This means that it is possible to write scripts which have one
particular behavior in a strict POSIX shell, which do not have the same
behavior in ash and other shells that implement "local".


I can't remember, but if there isn't one already there should be an
option in ash to enable "local".  My personal preference (not that it's
worth much) is that the default ash should be 100% POSIX (so "local" is
not supported in that mode), with extra options to enable extra
features.

And, the test script should work in the 100% POSIX with no extra options
enabled mode.

Apropos of nothing, I've already filed a bug in Ubuntu Launchpad saying
that "local" support should be removed from dash.  It doesn't work right
(where "right" is "the same way it works in bash") there anyway; I think
it's better to take it out than try to fix it, since it's not POSIX.

That's my $0.02 anyway.

> > -       mkdir -p ".tmpdir.$applet"
> > +       mkdir -p ".tmpdir.$applet" || return 1
> >
> > mkdir may report error when dir already exist - which
> > should be ignored.
> 
> Ok.  I've sinned :(
>         mkdir -p ".tmpdir.$applet" || :
> then?

As someone mentioned, this is not necessary and in fact, is arguably
incorrect.  mkdir -p will NOT print any message and will not exit with
an error code if the directory already exists.

It WILL print a message and will exit with an error code if it can't
create the directory for other reasons, such as permissions etc.

You don't want to ignore those other reasons, so I think you SHOULD
continue to catch errors from mkdir -p.




More information about the busybox mailing list