87 points · by zdw · 4y ago · 62 comments
The single executable file generated by the Cosmopolitan linker creates an insane polyglot binary executable that runs on 6 operating systems as well as on bare metal (i.e. bootable as its own OS); in addition, it's a valid Zip archive, and you can modify files inside it using any zip utility... fascinating stuff. On Linux, it bootstraps execution initially as a shell script, but the shell script writes the "ELF" file header and executes it (I'm probably doing a horrible job of explaining though).
If you're interested in learning more, this talk from 2021 is fascinating: https://www.youtube.com/watch?v=1ZTRb-2DZGs. It covers Redbean, a portable, run-anywhere web server built with the APE toolchain; since then Redbean 2 has been released, which adds a lot more features. Here's a link to Redbean: https://redbean.dev/
REM=;echo hello from sh;exit#
echo hello from cmdThis was because sometimes, the kernel would fail to execute a binary for some reason (this was the core bug), returning ENOEXEC to the libc, which, dutifully, would pass it on to the shell as documented in the article. Of course since the failed executable was a real binary, not a script, the shell would fail with the above error.
I haven't encountered the bug in a couple years, so I guess they finally fixed it. Silently.
taking just that part of the sentence out of context, that almost reads like some historical tome or some fantasy novel. or maybe it's that i lived a good chunk of the middle of last century and this kind of thing makes realize i've been doing this a lot longer than i'd like to admit
So even under that original meaning it fits.
But hey, don’t let me get in the way of some ignorant Windows-bashing.
"#" => "hash" (never had I heard it being called "pound")
"!" => "exclamation mark/point" (never had I heard it being called "bang")
So to me "#!" was "hash exclamation" in my college in home-country.
Then I went to USA for an exchange program, where people consistently called it "she bang" and "pound bang". Took me a while to get it.
Used in Unix-y circles since at least the 1980s, where "bang paths" were used for UUCP routing:
Notably I seem to recall I first encountered it as the symbol found on the forehead of Barry Trotter, a parody Harry Potter published in 2001.
DuckDuckGo also calls exclamation points bangs https://duckduckgo.com/bang
Octothorpe has never been its “proper” name in any country; just a jocular nickname originating in the US telco industry, which spread from there to computing.
#!/usr/bin/env
echo This might not do what you thought.Similarly, you can have your shell in the GECOS field be null, and again, you'll get the default shell. I think I had a bug report in with Sun complaining that XDM or the fancy XDM replacement didn't work correctly with a null shell value. Or maybe it didn't work if you had the character "ctl-l" as your password.
It's been a while. In any case, don't do these things.
when I learned unix around 1980, you had to start a shell script file with a single # on a line by itself, and there was no bang option... but I want to say there was a way to select sh vs csh, though I can't recall it... maybe you had to start with a couple lines of Bourneshell, and that part would relauch csh on the same file. can't remember though. A dozen years later that was a common technique to launch perl scripts tho I don't recall why.
I mean, it's basically what the article says. Anything that's not an executable and doesn't start with "#!" gets passed to the default shell. ":" is no exception here.
Indeed it does -- try logging in to your Linux machine with your username in all-caps :-)
Old as it is, I'm sure these are still around in some production environments.
I think the designers of Unix were (in part) reacting to some systems they'd experienced (such as IBM mainframes) which had very rich–yet complex, cumbersome and rigid–file metadata, and in reaction decided to make file metadata as simple as possible. The idea that you could support richness with simplicity (extended attributes as arbitrary name-value pairs, leaving the name and value format mostly up to applications) didn't seem to emerge until much later. I could be wrong about this, but I think contemporary Unix-like systems actually borrowed the idea from OS/2 (which in turn was possibly somewhat influenced by classic Mac OS resource forks)
Aren't verbs after "did/didn't" always supposed to be in the present tense? For example you would say "I didn't see you last night" rather than "I didn't saw you last night". Is there a grammatical rule I'm missing?
[1] the other one was this video by youtuber Vsauce, https://www.youtube.com/watch?v=vjqt8T3tJIE
EDIT: wow so many interesting responses, thank you!
This article says that in American English it’s considered an error, but it’s accepted in British English
I think that “used to” is the form seen so often that “use to” just looks and sounds weird to me. I would never use it
I like this last part of one of the answers in particular:
> One of the strongest arguments against treating used to as a standard verb form is the pronunciation. According to the Cambridge Dictionary, with the verb form of use, the s is voiced /juːz/ whereas in the noun form it is not voiced /juːs/. In I used to and I didn't used to, the s is unvoiced. It's definitely not a noun, but it is also not a standard verb form: it is something unique, and that's what upsets the grammarians.
Aside, like sibling comment, I'm also a native American English speaker and it's always been "didn't used to".
[0] https://ell.stackexchange.com/questions/100674/didnt-use-to-...
https://www.merriam-webster.com/words-at-play/is-it-used-to-...
There’s long been open debate among linguists about what might be formally more correct, but with sound arguments on both sides. It mostly comes down to grammatical rule vs idiomatic phrase with a strong validating history.
That said, he suggests never used to as a way to escape the grammar debate while still keeping used.
”Unix never used to support shebang” almost makes it seem like it just happened.
---
That's the opposite of what your source says:
> In writing, however, use to in place of used to is an error.
Used to X was the standard past tense of to use in the sense of being in the habit of:
I used to fish: I was previously in the habit of fishing, correct both in the past and today.
I use to fish: I am presently in the habit of fishing, correct in the past but no longer understood today.
The second, however, is according to MW occasionally misused to mean "I was previously in the habit of fishing".
> The problem becomes a little trickier in constructions with did. The form considered correct following did, at least in American English, is use to. Just as we say "Did he want to?" instead of "Did he wanted to?," so we say "Did he use to?" instead of "Did he used to?" Here again, only in writing does the difference become an issue.
> While in American English "did used to" is considered an error...
Personally, didn't used to looks jarring, but it made me open the article so…
Including the "didn't" in the search shows that it's still close though: https://trends.google.com/trends/explore?date=all&geo=US&q=d...