hyxogen / crash Goto Github PK
View Code? Open in Web Editor NEWA posix compliant shell written in C89
A posix compliant shell written in C89
crash ============ crash is our implementation of the 42 common core project "minishell" in C89. However unlike what the subject requires, we've built a fully posix compliant shell. crash stands for Can't Rest Again SHell which we (kind of derived) out of the pain it is to implement a standard compliant shell. using our shell ============ To compile crash, you'll need to have readline headers and the readline shared library. Which you can install with your favorite package manager if not already installed. Once you have readline, using crash is as easy as just cloning the repo and calling "make" in the root repo directory. As far as we know, it should work on any unix system, but your milage may vary. It has been tested to work on MacOSX 11 and Linux. After the sources are compiled, you should be able to start the shell with ./crash If you're wondering what this shell can do, you can take a look at the test/scripts/ directory for some examples. In theory all posix compliant shell scripts should work with crash. Our shell also supports a rc file called .crashrc, which you have to place in your user's home directory what the project required us to do ============ x Display a promt when waiting for a new command x Have a working history x Search and launch the right executable (based on PATH etc.) x Cannot use more than one global variable x Handle single qoutes '' x Handle double quotes "" x Implement basic redirections <,>,<<,>> x Implement pipes x Handle enviroment variables x Handle $? x Handle ctrl-c, ctrl-d and ctrl-\ x Implement the following builtins x echo with option -n x cd with only a relative or absolute path x pwd with no options x export with no options x unset with no options x env with no options or arguments x exit with no options x && and || with parenthesis for priorities x Wildcards * should work for the current directory Using only these externel functions: readline, rl_clear_history, rl_on_new_line, rl_replace_line, rl_redisplay, add_history, printf, malloc, free, write, access, open, read, close, fork, wait, waitpid, wait3, wait4, signal, sigaction, sigemtpyset, sigaddset, kill, exit, getcwd, chdir, stat, lstat, fstat, unlink, execve, dup, dup2, pipe, opendir, readdir, closedir, strerror, perror, isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr, tcgetattr, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs what we actually did ============ x everything in the mandatory and bonus part x while/until loops x if statements x functions x subshell x case clause x command substitution x background commands x all io redirect x bang symbol x proper expansion x arithmetic expansion x script files support x rc file x shift x set/unset x getopts and much much more... all according to the X/Open XSI Shell Command Language (Issue 4, Version 2) what we learned ============ Shells are poorly standardized, multiple times when we were implementing something, we read something along the lines of "some shells do it like this, and other shell do it like that. So for maximum portability do both"... Which we then did. Also there are times when the standard (at least the one we used) is just plain unclear about what something should do, making us check with multiple other shells what their behaviour is. And learning that even the big shells like bash and zsh do not have the same behaviour is some cases. Jokes aside, we definitely learned a great deal about annoying parsing. Resulting in the parser calling the lexer, and that lexer again calling the parser and on and on and on... And how to properly manage child processes and managing signalls. And perhaps most of all, we know pretty much understand all (standard) shell language. Knowing what to expect with what syntax. And also knowing the small things like how spaces (do not) expand. faq ============ Q:why so many files with so little amount of functions A:the subject requires you to work in a specific format, which limits you to max 25 lines per function, and max 5 functions per file
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.