wow, that's incredible. there's, like, 4 different techniques going on in there that I don't understand- and I would have said I understood javascript pretty well.
This is extremely cool, however the source code does look a little different than the output (the output only has '#' chars, but the source has letters and other chars besides #). Does that still count as a quine? (don't really care though... this is very cool).
Any idea how this works? It's just to much for my mind to bear I think.
I'm not sure what you're talking about. The output is the entire source with the central globe rotated by a user-selectable number of degrees, including 0. The output isn't just the globe in the center.
Edit: Ah, nvm. It looks like this is a Javascript port of a famous Ruby quine from 2010, the Qlobe[1].
I is not 'exactly' a quine, because the tool 'cat' is a program on its own, and not a shell command. Still, it is an entertaining and unexpected outcome.
I'm curious to know where the line of a "program" goes. I imagine a OS without file system, but only with functions (like as if emacs was an OS). Would a function then be called a program?
Well, if your EmacsOS allocates exclusive adress-space for the function-call, so that it can be executed in a very own execution context, independent of other function-calls... then you could call it a program.
I like the fact that #!/proc/self/exe causes the interpreter to be the calling program (since the interpreter is evaluated in the context of the calling program, from the kernel).
It’s often used to have your shell scripts fail fast by using `#! /usr/bin/bash -e`; which you could also do by using `set -e` at the beginning of the script but that’s less elegant.
I'm fairly sure `#!./quine` will cause an error because there's a limit of 5 recursive checks to find the interpreter of a script (fs/binfmt_script.c).
Presumably then, whatever shell you're using decides to just execute the code as a subshell rather than use execve(2). Can you dtrace it to figure out whether it actually calls execve(2)?
0 51617 execve:entry sh ./quine
1 51617 execve:entry sh /bin/sh
1 51617 execve:entry sh /bin/cat
Altho this is the first time I use dtrace. I can try to run another command you can ask me to.
My login shell is the Bourne shell. However I tried bash, csh and tcsh too, it works, so it's probably the system level code that substitutes /bin/sh (maybe because it's my login shell?) to the interpreter.
I remember being surprised by this and then realising, "wait, of course it's in the kernel -- that's so much nicer from a usability and sanity standpoint".
- The shell finds opens up the file you want to execute
- It gets the first line of the file
- It figures out what program to execute
- It calls fork()
- In the new process, it executes the program (using exec()) and passes the file as the input to the program.
http://aem1k.com/world/