Anyone ever had a go at writing a Linux/Unix shell? Or know where I can find some good info or tutes?
-RJ
Printable View
Anyone ever had a go at writing a Linux/Unix shell? Or know where I can find some good info or tutes?
-RJ
No, but you can try and find the POSIX shell interface guidelines (the ones that bash is supposed to be following :D)
I know the POSIX guidelines I want to follow. More need implementation stuff. Especially about piping commands, and redirecting output/input...
popen(), perhaps? :)
Or just look at the bash source.
Probably the hardest part is the actually parsing interface, and this is where the readline library comes in...
I have the functions for opening and using a pipe, it's more the design. I'm pretty unfamiliar with Unix/Linux, so I only have a rough idea of how piping works.
What's in the readline lib?
I have a few things I have to do. The first is to make some inbuilt commands, like cd, etc. The second is to implement I/O redirect with >, < operators, and the last is piping.
Gonna be quite a mission for a 2 week job... :p
P.S - I downloaded the bash source today. It's about...oh... 300 files... :eek:
Huge, isn't it.
But that's because most shells are also programming languages :D
The readline library does things like the history, command-line editing, stuff like that.
Sorry, exactly 820 files.... :(
In addition to my PM, you might want to look at the glob function, it's quite useful.
Will do. What's it do?
It performs "globbing", otherwise known as filename expansion. For example, if I glob the following:it could possibly expand this to:Code:mike@relativity ~] > ls *.txt {a,b,c}.dat
Code:ls z.txt ache.txt lada.txt a.dat b.dat c.dat
Yes, I was right amidst writing a set of classes to do this when I stumbled upon this function.
Ok, will check it out. :thumb:
Oh wait, that doesn't work here... :p