Hacker News new | past | comments | ask | show | jobs | submit login

This is interesting to me given https://github.com/NixOS/nix/issues/10823

We have a decent amount of code in bash that I'd like to get working on Windows too, once Nix on Windows is ready. I'm happy to rewrite it to a better language, but if I can get a non-CygWin/MSYS2 bash-compatible shell, that's a very nice thing to try out.






The easiest way to get POSIX and bashish scripts working on Windows is the busybox port:

https://frippery.org/busybox/index.html

This is actually the Almquist shell with many bashisms brought in (no arrays though).

  C:\>\bin\busybox sh
  C:/ $ uname -a
  Windows_NT MyHostname 10.0 22631 x86_64 MS/Windows
Edit: The ADA port below might interest you.

https://github.com/AdaCore/gsh

https://archive.fosdem.org/2019/schedule/event/ada_shell/


We do use bash's arrays and maps, though.

at the time it was mainly implemented to speed up compiler builds. Not using a cygwin based shell allowed a 3-5 speedup which was significant for our nightly builds

Just out of curiosity, how much faster is gsh than busybox?

I believe that busybox is produced by the Windows cross-compiler that I have loaded from EPEL. Can gsh be built the same way?


I never did the test. At the time we started the project busybox was not sufficient to use in a full build of gcc, binutils, gdb, ...

Though I never tried using a cross compiler to compiler GSH should not be an issue


This is the MinGW cross-compiler for Windows that I found in EPEL.

Alas, no ADA.

"Using this toolchain allows you to build binaries for the following programming languages: C, C++, Objective-C, Objective-C++ and Fortran."

https://fedoraproject.org/wiki/MinGW/Tutorial

I think all of these packages were pulled in the "yum install":

  $ rpm -qa | grep ming | sort
  mingw64-binutils-2.41-3.el9.x86_64
  mingw64-cpp-13.2.1-7.el9.x86_64
  mingw64-crt-11.0.1-3.el9.noarch
  mingw64-filesystem-148-3.el9.noarch
  mingw64-gcc-13.2.1-7.el9.x86_64
  mingw64-headers-11.0.1-3.el9.noarch
  mingw64-libgcc-13.2.1-7.el9.x86_64
  mingw64-winpthreads-11.0.1-3.el9.noarch
  mingw64-winpthreads-static-11.0.1-3.el9.noarch
  mingw-binutils-generic-2.41-3.el9.x86_64
  mingw-filesystem-base-148-3.el9.noarch

if you have interest i could have a look at adding support for these structures in gsh

I am not sure if this helps or not, but if you want a bash-compatible shell on Windows, translating Oils to Ada, or porting it to Windows could be easier than adding bash arrays

https://news.ycombinator.com/item?id=43910883 (similar comment about Rust)

Bash arrays are extremely hairy, with many corner cases, and differ from bash version to version.

And in particular, the shell code in Nix DOES RELY on these corners (e.g. https://www.oilshell.org/blog/2024/06/release-0.22.0.html)

---

I mentioned in another comment that Koichi Murase, who is a bash contributor, and wrote the largest shell program in the world, just overhauled the bash array support in OSH

A few relevant test files -- Koichi added a huge number recently:

https://oils.pub/release/0.29.0/test/spec.wwz/osh-py/array-s...

https://oils.pub/release/0.29.0/test/spec.wwz/osh-py/array-a...

https://oils.pub/release/0.29.0/test/spec.wwz/osh-py/ble-idi...

Our tests are thorough enough that we ROUTINELY find bugs in bash, like integer overflow bugs.

Koichi also knows about the differences between say bash 4.3, 4.4, 5.0, 5.1, etc. Because he wrote a very large program that uses bash arrays all over the place.

---

Feel free to use our tests in any case (other shells like the Scheme shell used to bootstrap Guix have)

And feel free to post a message to https://github.com/oils-for-unix/oils if you're interested or have questions


Does YSH work on Windows?

It doesn't, but in the last ~3 months I've come around to the idea that it should

And I did a bunch of research on it (e.g. https://lobste.rs/s/qjzd9y/everyone_quotes_command_line_argu... )

I did notice that git for windows uses a bash built with MSYS. And I noticed that Python's subprocess module implements pipelines with native Win32, not with MSYS.

So that is something we can do in Oils, in theory

I won't say it's high priority, but of course it's an open source project, and users often change the priorities

Two things that would really help are (1) finding a skilled Win32 programmer and (2) getting another grant (we've gotten 3 in the past)


OK thanks for the status update. I'll keep on eye on this.

That's good to know! I would say our Windows support is not yet at the point where I would feel comfortable making a feature request to your project, but let's keep in touch. :)

The old "it's easier to port a shell than a shell script" quote comes to mind (:

there's the cosmopolitan libc one: https://cosmo.zip/pub/cosmos/bin/bash

you'd probably want the rest of the programs, too. bash isn't too useful on its own. you can also find those on the same website




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: