Drop posix sh support for crosutils common.sh?

11 views
Skip to first unread message

Brian Harring

unread,
May 7, 2012, 1:22:24 AM5/7/12
to Chromium OS dev
Directing folks attention to src/scripts/common.sh in your local repo, currently it purports to be posix sh compliant, meaning it would be usable by dash  The problem here is that common.sh isn't actually able to be parsed by dash (the closest adherent to posix sh I know of).

The question is do we actually care?  This slipped past since /bin/sh on most systems is bash, combined w/ the fact basically all but 2 scripts in crosutils have explicit bash shebangs.  My personal preference is to forego posix sh w/in crosutils/build scripts, requiring bash; minimally for anything consuming common.sh.

Anyone have a complaint w/ dropping posix sh support?  As said, it's basically gone from crosutils at this point via our shebang usage.
~brian

Kees Cook

unread,
May 7, 2012, 1:51:39 AM5/7/12
to Brian Harring, Chromium OS dev
I have no problem with dropping posix sh support, but my rule of thumb
has traditionally been: "if it needs more that posix sh, it shouldn't
be written in shell." :)

-Kees
> --
> Chromium OS Developers mailing list: chromiu...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en



--
Kees Cook
Chrome OS Security

Hung-Te Lin

unread,
May 7, 2012, 3:27:21 AM5/7/12
to Kees Cook, Brian Harring, Chromium OS dev
The one really need to be dash-compatible now is chromeos-common.sh (used by installer & others, since /bin/sh on ChromeOS is dash), so I think it may be fine to drop posix sh support  for src/scripts/common.sh .

But I agree with Kees - if we're really writing something that cannot be handled by posix sh (dash), then it probably shouldn't be bash, either. And that means trying to keep every scripts POSIX sh compatible is not bad...

Current common.sh is almost dash-compatible, except:
    - Few functions (ex, sudo_multi, choose) used bash array
    - Some functions start with "function" and should be removed
    - Few [[ can be converted to [

So we're not using too much bash-specific syntax except the Array.

Regards,
Hung-Te

Chris Wolfe

unread,
May 7, 2012, 11:19:20 AM5/7/12
to Hung-Te Lin, Kees Cook, Brian Harring, Chromium OS dev
Disagree. Most of the developer scripts will never be run on device,
so if bash makes the code cleaner than sh it's a good thing.

Nothing "needs" more than posix sh. IMO, however, a fair number of the
scripts are cleaner with bash features than without. And much cleaner
in a shell than mangled into Python.

Chris

Matt Tennant

unread,
May 7, 2012, 11:35:45 AM5/7/12
to Chris Wolfe, Hung-Te Lin, Kees Cook, Brian Harring, Chromium OS dev
Answering Brian's orignal question, I think the most empirically
accurate answer is that people do not care because nobody has
noticed/complained about the lack of posix sh compliance over many
months.

Matt
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages