ibara / oksh

Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
352 stars 38 forks source link

[question] similar projects for other BSDs shells? #47

Closed avih closed 3 years ago

avih commented 3 years ago

Hi,

First, thanks for maintaining this. It's very useful for testing OpenBSD shell behavior on linux.

I'm interested in writing practically portable shell scripts (see shcmp), and I'm generally familiar with shells history, but not so much in the BSD world.

I was wondering if you're familiar with projects similar to this one but for default shells on other BSDs (I'd think mainly FreeBSD and NetBSD, but possibly dragonfly too). I am familiar with loksh, though it's basically the same as this project except maybe for portability scope (and indeed I don't recall cases where shcmp produced different results for oksh and loksh).

Additionally, maybe you know a bit about the relations between the default shells on different BSDs? I know OpenBSD [k]sh is based originally on pdksh, and I think FreeBSD sh is a rewrite or evolution of ash, and its closest cousine on linux is likely dash, though I'd guess they've diverged enough to not assume identity. I don't know about other BSDs.

Thanks in advance.

ibara commented 3 years ago

I don't think there's any separate or special shell history specific to the BSDs. Just the history of shells, some of which happen to be developed and maintained by BSD projects.

/bin/sh is: ash on FreeBSD, NetBSD, and DragonFly ksh on OpenBSD

I'm sure ash on FreeBSD and NetBSD are mostly compatible, slightly diverged. ash on DragonFly may just be a direct vendor sync from FreeBSD with any needed patches on top.

oksh and loksh shouldn't generate different outputs ever (modulo syncing with OpenBSD). You're right, our scopes are different: loksh aims solely at Linux, whereas oksh aims for as many environments and compilers as possible.

avih commented 3 years ago

Thanks.

So you're not aware of projects aiming to build the FreeBSD or NetBSD sh (i.e. with their current code base) for linux or other platforms?

ibara commented 3 years ago

I would imagine that with the existence of dash, no one finds it necessary to port ash. Repology.org also doesn't know of any modern ash port to another operating system.

avih commented 3 years ago

Sure, dash is quite fine, but as I bet you know the devil is in the details, and some shells do mostly fine except where they don't (for instance, OpenBSD ksh doesn't apply "$@" correctly when IFS is non-standard).

So for the sake of compatibility testing, it's not enough to assume IMHO that if it works in dash then it would also work in BSD ash.

Anyway, thanks again. Maybe I'll try to ask the NetBSD folks about it.

avih commented 3 years ago

Hmm.. now that I think about it, does OpenBSD have ash which is reasonably close to FreeBSD and/or NetBSD ash? If yes, maybe the oksh portability framework could be used to build that as well?

ibara commented 3 years ago

The "$@" bug has been fixed: https://marc.info/?l=openbsd-cvs&m=160001156508985&w=2

There is no ash in OpenBSD's sources. It was removed something like 20 years ago. /bin/sh is ksh. I did however make a port of NetBSD ash some time ago to do some unrelated work: https://github.com/ibara/ash You can build it with make obj && make but make sure to run cvs diff first so you can see the changes I had to make.

avih commented 3 years ago

The "$@" bug has been fixed:

Huh, interesting. I reported it on the Sep 12th here https://marc.info/?t=159986957700001&r=1&w=4 and I've been following the thread, but there were no further replies so I assumed it just stalled again (previous time was 4 years ago).

I did however make a port of NetBSD ash some time ago to do some unrelated work: https://github.com/ibara/ash

Much appreciated. I'll take a look.

FWIW, I asked at #netbsd on IRC, and was told there are no ports of their default shell to other platforms.

(feel free to close this issue at any time)