LWN.net Logo

Has anyone considered extending dash?

Has anyone considered extending dash?

Posted Aug 6, 2009 2:39 UTC (Thu) by dwheeler (guest, #1216)
Parent article: A tale of two shells: bash or dash

If dash implements the Single Unix Spec, then it does not HAVE to do more to meet that formal spec. But some of the "bashisms" are convenient, would add little to the size of dash, and would make it FAR easier to use dash as an alternative. Is anyone looking into what bashisms are "most popular" yet small, and perhaps should be implemented in dash as well? And, if they should, perhaps modifying the Single Unix Spec so that it includes those, too?

I don't think that dash should add everything that bash already does; we already have bash. But it might be easier to use dash as /bin/sh if dash added a few of bash's conveniences.


(Log in to post comments)

Has anyone considered extending dash?

Posted Aug 6, 2009 14:07 UTC (Thu) by fbriere (subscriber, #4961) [Link]

Is anyone looking into what bashisms are "most popular" yet small, and perhaps should be implemented in dash as well?

Section 10.4 of Policy lists three such exceptions (namely, "echo -n", "test -a/-o" and "local"). They are not in the standard, but are deemed useful enough to be required of any shell claiming /bin/sh.

And, if they should, perhaps modifying the Single Unix Spec so that it includes those, too?

I wouldn't hold my breath on that one. :)

But it might be easier to use dash as /bin/sh if dash added a few of bash's conveniences.

Any script requiring bash features can always specify #!/bin/bash on its first line.

The issue with bashisms is not about people needing specific bash features, but about people not knowing that they are bash-specific. The bash(1) manpage doesn't state which features are standard and which are not, and the standard itself is not always easy to find (or read, for that matter). The dash(1) manpage can serve as a gentler approach, but even dash doesn't strive for strict standards complicance.

As a result, most script maintainers are blisfully ignorant of what the standard requires. (I myself strive to adhere to the standard, yet I didn't know until recently that "." searching the current directory is a bashism.)

So, unless dash implements all of bash (which would rather defeat the point), any transition is bound to hit a few bumps on that road.

Has anyone considered extending dash?

Posted Aug 7, 2009 18:43 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

Any script requiring bash features can always specify #!/bin/bash on its first line.

And pay the price of Bash. The point is that it would be great if we could get the cheapness of Dash from many programs that were written for Bash.

The issue with bashisms is not about people needing specific bash features, but about people not knowing that they are bash-specific.
That's an important issue, but not the one that is the subject of this article. The instant issue with bashisms is that they exist today in scripts that specify #!/bin/sh, and that complicates making /bin/sh = Dash. Making Dash understand some bashisms can't completely solve the problem, but it could ameliorate it considerably.

The bash(1) manpage doesn't state which features are standard and which are not,

It also doesn't state which features are available in which versions of Bash, which makes it hard to write a #!/bin/bash program that works everywhere. And Perl and myriad programming libraries have the same issue. I'm expanding on this point to encourage people who write manuals for such things to consider including that information.

Has anyone considered extending dash?

Posted Aug 9, 2009 6:18 UTC (Sun) by jlokier (guest, #52227) [Link]

Not only that, but occasionally a new version of Bash will deliberately break something which worked in an older version of Bash. Just like Perl, really, but without the helpful warnings.

Has anyone considered extending dash?

Posted Aug 8, 2009 11:30 UTC (Sat) by marcH (subscriber, #57642) [Link]

> The bash(1) manpage doesn't state which features are standard and which are not,

I never use the Bash's man page. Bash's info manual has a "Features found only in Bash" section and is much better generally speaking. If, like many other people you dislike the basic info reader there are a number of alternatives like for instance "yelp info:bash"

> and the standard itself is not always easy to find (or read, for that matter).

Every time I have a doubt about standard conformance I just google for "opengroup + sh-keyword" and most of the time I just land automagically on a page that answers my doubt. In the worst cases the answer is only a few further clicks away.

Has anyone considered extending dash?

Posted Aug 13, 2009 17:23 UTC (Thu) by fbriere (subscriber, #4961) [Link]

> Bash's info manual has a "Features found only in Bash" section and is much better generally speaking.

Thanks, that's good to know. (Looking at it, I believe I might have erroneously used pushd/popd myself.)

However, it appears to be a list of generic features, so it's far from a thorough list. While the "Bash POSIX Mode" subsection goes into more detail, I didn't see any mention of, for example, bash-specific expansion patterns like ${foo/bar/baz}.

> Every time I have a doubt about standard conformance I just google for "opengroup + sh-keyword"

Unfortunately, bash (like Perl) has gobs of Google-unfriendly concepts. (Searching the standard for "." was fun...)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds