Remove (some) bashisms from the test scripts

Uri Simchoni uri at samba.org
Sat Dec 23 19:38:06 UTC 2017


On 12/22/2017 11:05 AM, Timur I. Bakeyev wrote:
> On Fri, Dec 22, 2017 at 9:35 AM, Uri Simchoni <uri at samba.org
> <mailto: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.
> 

As for the patches - RB+ me. Can I have another Team reviewer?

Other than that:
Just to make things clear - the Samba test suite policy has always been
not to assume that /bin/sh is bash. On the build server, /bin/sh is
dash. It appears the "bashisms" you pointed out never execute during
selftest (which means we don't have tests for adding/removing/modifying
shares via RPC...).

Having run checkbashisms myself now, there seem to be many more. Other
than false positives, there are:
1. uses of "echo -n"
2. unsafe echo with backlash (e.g. echo '\nFoo' - that's XSI-compliant)
3. uses of "echo -e"
4. 'command' with option other than -p (it's with -v which is XSI-compliant)

What do you make of those w/respect to FreeBSD? (seems like 1 and 3 are
supported, 2 and 4 are not...)

Thanks,
Uri



More information about the samba-technical mailing list