Remove (some) bashisms from the test scripts

Timur I. Bakeyev timur at freebsd.org
Fri Dec 22 09:05:50 UTC 2017


On Fri, Dec 22, 2017 at 9:35 AM, Uri Simchoni <uri at samba.org> wrote:

> On 12/22/2017 03:58 AM, Timur I. Bakeyev via samba-technical wrote:
> > Yet another fixes to make self-test work out of the box on FreeBSD.
> >
> > Despite having '#!/bin/sh' in the test shell scripts there are some
> > bashisms present,
> > that make FreeBSD sh croak.
> >
> > I've run Debian's 'checkbashisms' script against test scripts and tried
> to
> > address most of it's (reasonable) warnings.
> >
> > Also, one failing test spotted the place where direct call to the
> > 'ldbsearch' wasn't replaced with the configurable path.
>
> We have another possible path - mark scripts which use bash syntax as
> #!/bin/bash (or even "standardize" on bash).
>
> There are tests which are truly bash-specific - I might have introduced
> the first one and the bash dependency was discussed on the list (using
> bash arrays - the shadow_copy2 test). I also (hours before this patch
> submitted :)) updated the Samba wiki about the need to have bash to run
> tests.
>
> I personally find the bash syntax less error prone ([[ vs [ mostly) and
> would prefer to keep the "bashisms" as bash scripts instead of shell
> scripts, but I can see how there can be strong opinions to the other
> side, so we should first solicit input on that and decide on the general
> direction.
>

Well, bash is evil and should be avoided, whenever it's possible, IMHO.
In general if you care about any kind of portability it should be avoided.

Unfortunately, we can't dictate here, so have to follow the path that Samba
project will chose, but if you going to introduce such a dependency, please,
remember that bash for FreeBSD is a foreign program, so it'll be in
/usr/local/bin/bash. Hence you'll have to apply the same magic you used
for the Perl.

And, as of the given patch - the bashisms we see are, clearly results of the
inaccurate programming, where POSIX shell was meant, but some foreign
elements did slip into. There isn't anything Bash specific in those
scripts, just
some syntax elements wrongly used. And, being prefixed with #!/bin/sh they
demand the wrong guy to do the job.

So, we can coop with bash in FreeBSD, but those particular scripts don't
really
require it and I think, on that matter shouldn't demand it and use it's
syntax.

With regards,
Timur Bakeyev.


More information about the samba-technical mailing list