trying to make a zsh-like shell for windows

hi, i'm trying to make a zsh-like shell for windows, but i'm having some trouble to do command parsing, pipe handling, etc on windows because every tutorial i found on the internet only works for linux, and i want to do the command parsing part first before the rest.
is there any way to do at least the command parsing part on windows? here's my code:
You may want to consider handling each keypress interactively to support command completion. You'll need to use platform specific features for this, plus wide character support.
something i could do is to use the zsh source code as the base for my code, instead of trying to convert the code to windows.
well, technically i'm converting the code to windows, but you got the point.
Last edited on
nevermind, i'm too dumb for this at the moment. maybe in the future i'll make something way better than that.
well, if i continue acting like that i'll not manage to make my own operating system in assembly, so i should work ground up.
Cygwin has a zshell, and I think most if not all of their source code is out there on the web. Could study it but its probably a complicated port of unix source code.
yeah, i saw.
The cygwin port won't help, it's probably just the Linux code compiled against the cygwin runtime. So the code won't need to be ported.

When all this port to Windows business started, GNU tools were rewritten for Windows and ran natively. There was the MKS Toolkit that did what Cygwin does, present a Unix layer for Windows. But that was a commercial product (money, licence, ...). Redhat worked on cygwin, and the rest is history. Most Unix apps now run on Windows under some kind of Unix emulation, like cygwin.

You're proposing writing a native zsh. It's a daunting task. You could start with your own Bourne Shell, and use the experience gained from that for your zsh. It's not a trivial task.
Last edited on
yeah, this is what i was thinking about to do, i would first write a basic sh-like shell and then make the zsh-like shell.
i could start by using the debian almquist shell source, and then, in the future, use the zsh source code as the base, so it would look like a bit mixed between two different shells.
It's probably best to start from scratch.

There's lots of stuff in a shell, much of which you're probably not aware of right now. I suggest you start with one feature at a time, starting with the ability to start a program. This way you'll become more knowledgeable about all shells.

You'll also learn about differences between fundamental things in both platforms that you'd not have considered before; like controlling terminals in Unix, and controlling consoles in Windows, differences in process creation and management, IPC, security, ...

It's not a waste of time, even if you don't finish it.
Last edited on
i agree.
My best suggestion is to learn how to write a parser. YACC (or BISON if using GNU) is a great tool. Very useful in writing command parsers, languages and interpreters.

At the simplest level a parser takes input (text) tokens and converts them to "productions". A production is a combination of one or more tokens that represents an element of a command or language. Productions are combined and reduced until the entire input has been processed.

YACC can be daunting at first, but well worth the learning curve. It helps if you understand Backus-Naur Form (BNF).

Command shells are relatively easy if you can specify the BNF for them, run the BNF through YACC and then just write the code for the productions.
Last edited on
Topic archived. No new replies allowed.