[lxc-devel] using posix shell instead of bash

Stéphane Graber stgraber at ubuntu.com
Wed Nov 14 19:00:15 UTC 2012


On 11/14/2012 01:50 PM, Michael H. Warfield wrote:
> On Wed, 2012-11-14 at 09:54 -0600, Serge Hallyn wrote:
>> Quoting Natanael Copa (ncopa at alpinelinux.org):
>>> Hi,
>>>
>>> I wonder if it there are any interest to make the scripts posix shell
>>> compliant so they can run with for example busybox ash and dash.
>>>
>>> I would like to provide proper LCX support for Alpine Linux, which by
>>> default runs from tmpfs. It uses uclibc and busybox as the base system,
>>> which makes it very lightweight. Looking at the scripts, it seems like
>>> it would be fairly easy to adjust the script to not depend on bash at
>>> all, making it possible to make the LCX host even lighter.
>>>
>>> Before I start with sending patches, is this something that you would
>>> be interested in, or are you married with bash (like the vserver ppl)?
> 
>> I don't think anyone is married to bash here.  The debian package has
>> changed some scripts from bash to sh.  I'm only leery of resulting
>> breakages and reports of subtle time-consuming bugs, and potentially
>> less-maintainable code.
> 
>> (Note also that lxc-ls may be rewritten in python.  Is that a problem
>> for your use case?)
> 
> Some reason?  Sorry.  In my "day job" I have to maintain code written in
> C, bash, sh, ash (I wrote and array function library for ash and
> busybox), perl and python, including a raft of stuff that interfaces to
> web scrappers and SQL databases.  My team and I find python to be the
> least maintainable and all the cruft that our predecessors wrote in
> python is getting rewritten in perl so it can be maintained as soon as
> we figure out what the hell they did in there...  We had one guy who was
> absolutely in love with python and django and left us with a mess.  Now,
> that may well be his fault to begin with being that it is uncommented
> highly recursive web processing code (yes it uses "beautiful soup") that
> drives us all nuts and breaks with nothing more that the classical
> python backtrace.  I know a lot of people are just in love with python
> but I wouldn't just rewrite it unless there was a really good reason to.

The reason is that we have API bindings in python which let us directly
access any function from the C API instead of having to do wild guess
from the shell scripts or limit the possible features as is done currently.

In my experience, the readability of the code has little to do with the
language, it tends to have a lot more to do with who wrote the code to
being with ;)

>>> Would you be prepared for minor sacrifices to use posix compliant shell
>>> scripts?
> 
>> Someone else can jump in if they object, but I personally don't.  Are
>> you willing to subscribe to github.com/lxc/lxc#staging commits and
>> watch for new commits re-breaking posix compliance?
> 
> Converting from bash to ash (which is very sh like) isn't too bad if you
> are not making extensive use of arrays and string functions.  It's
> probably doable (having done it myself with some fairly sophisticated
> bash scripts dealing with LUKS encryption and file systems).  I would
> start by trying to run it under busybox ash and see what breaks.

The target really should be pure POSIX shell and nothing else, this will
guarantee that the code will work on the standard shells like busybox's
sh, Debian's dash and the good old bash.

The checkbashisms command can be used to spot any of the usual bashims
(once the script has been changed to use #!/bin/sh).

>> Successful runs of https://code.launchpad.net/~serge-hallyn/+junk/lxc-test
>> with your patches will also be reassuring.
> 
>> -serge
> 
> Regards,
> Mike
> 
> 
> 
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> 
> 
> 
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20121114/30beb508/attachment.pgp>


More information about the lxc-devel mailing list