←back to thread

217 points tanelpoder | 1 comments | | HN request time: 0.202s | source
Show context
jandrese ◴[] No.26492618[source]
This seems to be more of "don't paste garbage into a terminal, especially as root." With a sidenote that it might be safer if your custom application command interpreter didn't use > as the prompt character. I note that Bourne shell defaults to the safer % and # characters for the prompt. The # character for root is especially safe.
replies(6): >>26492739 #>>26492951 #>>26494723 #>>26499063 #>>26499191 #>>26501459 #
rcarmo ◴[] No.26492739[source]
Yeah. About the only relevant bit is that root prompts tend to use # as part of their prompt precisely to inject a comment character in case of mis-quotes/pastes.
replies(2): >>26492855 #>>26496214 #
minitoar ◴[] No.26492855[source]
Wow I never heard that! I always thought it was just some arbitrary convention I guess.
replies(4): >>26494208 #>>26494966 #>>26494988 #>>26498663 #
taviso ◴[] No.26494988[source]
I've heard this story before, but I don't think it's true.

I think the bourne shell copied # comments from csh, which had them first. When sh first implemented them, # comments only worked in scripts, not if you typed them at the shell (i.e. if isatty(0), then # wasn't special). The fact that the prompt came before comments, and that comments didn't work interactively really makes the story sound suspect!

I don't know the origin of # in csh, but I would guess it was chosen because it looks like a CPP directive.

replies(4): >>26495178 #>>26495629 #>>26495972 #>>26528534 #
1. dfox ◴[] No.26495972[source]
I don't have reference for that but I always though that CPP directives are preceded by # because the character was previously used as comment delimiter by something (probably csh). In the grand scheme of things cpp is somewhat modern invention. IIRC the first book on Unix programming I had read mentioned in passing that cpp exists but the C code examples in there did not #include anything and if some declaration was required it was just written verbatim in the example code.