Reading the sorce code for cmd gave me my first "I am enlightened" moment when first programming in Python.
"You mean I just add a do_functionname method and that gives me a functionname command in the shell? And I can understand the 'refection' code that does this, and it dosen't look like incredibly verbose black-magiv-voodoo? I'm sold"
The python prompt toolkit is very nice too, providing a lot more modern functionality (eg syntax highlighting, mouse support, suggestions). http://python-prompt-toolkit.readthedocs.io/
Another fun thing you can do is create a shell that only runs with the '-c' command line flag. If this is set as the default shell for a user, then you can use ssh as a simplistic rpc transport.
The funny thing is that I was literally just wondering about how shells are implemented right before getting on HN. Thanks for sharing, this should prove most useful :)
It covers a lot of stuff in an authoritative way. For example, how one should implement a daemon properly (e.g., chdir to root to allow for unmounting the disk the program originally ran from, lots of stuff like that). I'll actually doubly recommend it, because it's so good.
There are many ways that one might; perhaps the simplest might be to just define them as a builtin to your shell that checks the exit code of the left-hand command, and executes or doesn't the right-hand command accordingly.
[+] [-] acoderhasnoname|9 years ago|reply
[+] [-] Marazan|9 years ago|reply
"You mean I just add a do_functionname method and that gives me a functionname command in the shell? And I can understand the 'refection' code that does this, and it dosen't look like incredibly verbose black-magiv-voodoo? I'm sold"
[+] [-] rogerbinns|9 years ago|reply
[+] [-] pacaro|9 years ago|reply
[+] [-] hackeradam17|9 years ago|reply
[+] [-] csl|9 years ago|reply
It covers a lot of stuff in an authoritative way. For example, how one should implement a daemon properly (e.g., chdir to root to allow for unmounting the disk the program originally ran from, lots of stuff like that). I'll actually doubly recommend it, because it's so good.
[+] [-] unknown|9 years ago|reply
[deleted]
[+] [-] rhinoceraptor|9 years ago|reply
[+] [-] munyari|9 years ago|reply
[+] [-] OJFord|9 years ago|reply