Mailinglist Archive: opensuse-factory (602 mails)

< Previous Next >
Re: [opensuse-factory] Can we assume that /bin/sh is bash?
On Fri, 2019-02-08 at 14:25 +0100, Jan Engelhardt wrote:
On Friday 2019-02-08 13:22, Martin Wilck wrote:
I'm aware that, in principle, /bin/sh is supposed to be the Bourne
shell on Unix systems. But as a matter of fact, on current
openSUSE, it
is not.

But it could be. In fact, it can be. `zypper dup` yesterday with an
update block of 120 packages yielded only 7 scriptlet problems when
sh is dash.

For me the question is, what's the benefit? I mean, anyone can choose
whatever shell (s)he/ likes, but what's the point in having "/bin/sh"
point to it? Do you uninstall bash on your systems?

Is it size? Agreed, we could save ~800kiB in a minimal installation if
we were able to use dash instead of bash as the OS's basic shell. But
that would require a lot more work than just checking the scriptlets.
Nowadays, bash is even in the initrd.

If we can't assume that /bin/sh is bash, what else can we assume? I
recall from earlier work that writing really 100% compatible shell
code
for all kinds of environments is really hard.

No one needs to write sh-compatible code. The code just needs to be
annotated that it requires a certain interpreter. Since script files
already have a #! line most of the time, that's taken care of.

... unless that line reads '#! /bin/sh'.

That leaves script "snippets" that rely on implicit interpreters,
such as in .spec.

Since I literally get to see every new line of spec code due to
factory-review, many specfiles have already gotten their treatment
(if one was even needed). The upside is that specfiles don't need a
lot of work because everyone tries to keep them short anyway and
reuse macros due to the volume of it all.

What rules do you follow in this review work? Do you require POSIX
compliance? Or compliance with dash's features, which is not the same?
Do other reviewers follow the same rules as you do?

That's my point - IMO we'd need to define a reference and stick to it.
I really don't care what it is, as long as it's POSIX or a superset of
it. I've come to like bash's [[ ]] a lot but heck, I can live without
it.

Martin

--
Dr. Martin Wilck <mwilck@xxxxxxxx>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups