tokenrove / build-your-own-shell Goto Github PK
View Code? Open in Web Editor NEWGuidance for mollusks (WIP)
Guidance for mollusks (WIP)
Hey!
The hell link currently 404s because the author cleared out the original repo. Maybe either removing the link or linking to an old commit would be a good fix?
Thanks for putting this together, it's really awesome 🎉
Lexing into words, and the strange interrelationship with parsing, especially once quoting is introduced, is really hard, and we don't talk about it at all here. It will be easier to expand this when I make pedagoguish, frosh, and squish public, each of which uses a different parsing strategy.
Right now you don't get much, but it should probably print out the lines of the test description, or even replay a script
of the actual session with the shell, and highlight where things went wrong.
I tried running the tests with both bash
and zsh
and they both fail on the same test (05-and-or-chaining.t
)
❯ ./validate /usr/bin/bash
stage_1: 01-fork-exec.t 02-commands-invoked-from-path.t 03-cd-changes-directory.t 04-semicolon-separates-commands.t 05-and-or-chaining.t
# POSIX calls these AND Lists and OR Lists
→ true && echo-rot13 foo⏎
← sbb
→ false && echo-rot13 foo⏎
≠ sbb
→ true && false && echo-rot13 foo⏎
≠ sbb
→ false || echo-rot13 foo⏎
← sbb
→ true || false || echo-rot13 foo⏎
≠ sbb
→ false || true && echo-rot13 foo⏎
← sbb
→ nonexistent-command 2>/dev/null || echo-rot13 zim⏎
← mvz
---------------------------
You still need to do stage_1
Keep working!
Seems like they are failing on the last assertion of the test case:
→ nonexistent-command || echo-rot13 zim⏎
← mvz
I ran the tests in interactive mode and I believe the problem is that both bash
and zsh
are printing an error message for the command not found. Here's an example in a vanilla bash shell:
$ nonexistent-command || ./helpers/echo-rot13 zim
bash: nonexistent-command: command not found...
mvz
❯ expect -v
expect version 5.45.4
❯ bash --version
GNU bash, version 5.2.15(1)-release (x86_64-redhat-linux-gnu)
❯ zsh --version
zsh 5.9 (x86_64-redhat-linux-gnu)
Right now validate bash
gets up to the TTIN/TTOU exercise: https://travis-ci.org/tokenrove/build-your-own-shell/jobs/288734686
Ever since I rewrote the tests with silly Unicode characters, I wanted to have placeholders like σ for an arbitrarily quoted string, φ for a random file name, Γ for a globbable set of files and γ for the glob that matches, et cetera, to provide a modicum of property testing. To be effective, this should have shrinking, as well as a way to get the normative definitions of these variables (currently typically foo
and such).
me@DebianXfce23F:~/projects/lsh-shell/build-your-own-shell$ ./validate ../lsh
stage_1: 01-fork-exec.t
→ /bin/echo foo bar⏎
↵ foo bar
→ tr a-z n-za-m⏎
→ foo bar baz⏎
↵ sbb one onm
→ ^D
→ ./helpers/echo-rot13 foo bar⏎
↵ sbb one
→ ./helpers/echo-exit ./helpers/successful-exit-status⏎
↵ 0
---------------------------
You still need to do stage_1
Keep working!
Unsure where I am actually going wrong here, I think I poorly understand your "validate".
I've attached my C source code if you'd like to look through any of it to detect where I've gone wrong.
lsh.c.txt
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.