6 ms·
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 i
by jandrese 6y ago
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.
- eythian 6y agoI feel a better takeaway is "people are sometimes going to mess up, if you can do something easy to make those mess-ups less serious, it's probably worthwhile."
- rcarmo 6y agoYeah. 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.
- minitoar 6y agoWow I never heard that! I always thought it was just some arbitrary convention I guess.
- rcarmo 6y agoI _think_ it started becoming commonplace around the early days of X11, although to be fair # and $ are neighbors on pretty much any keyboard layout.
- alpaca128 6y ago> # and $ are neighbors on pretty much any keyboard layout Aside from ISO QWERTY, AZERTY and at least 3 different QWERTZ variants, among others.
- jodrellblank 6y agoNot UK layout; shift-3 is £ and # is next to enter. \ @ and " are in their proper positions on a UK layout as well. :| https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fquietpc.co.uk%2Fimages%2Fproducts%2Fmatias-quiet-pro-keyboards-10-large.jpg&f=1&nofb=1 https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2F...
- nemosaltat 6y agoThis is why I hang out here! Obligatory XKCD: https://xkcd.com/1053/ https://xkcd.com/1053/
- reaperducer 6y agoThis is getting to be a tired meme. While it doesn't apply to shell prompts, there are such things as cultural memory and institutional memory. As a member of a group or society, you are expected to have a certain baseline amount of knowledge of that culture and history. When I was young, it was considered shameful not to know things. Now the people I work with seem to wear ignorance as a badge of pride. They think that not knowing something means that thing is not worth knowing. As if somehow not knowing something is a good thing.
- chriswarbo 6y ago> Now the people I work with seem to wear ignorance as a badge of pride. They think that not knowing something means that thing is not worth knowing. As if somehow not knowing something is a good thing. That may be the case, due to attitudes encouraged by pop culture, etc. but it's a disastrously incorrect understanding of the comic (and parent comment). They're celebrating learning, which is the exact opposite of 'wearing ignorance as a badge of pride'. > When I was young, it was considered shameful not to know things. Shaming something discourages people from admitting it. A child who's ashamed to ask questions will not learn as effectively. They may learn to avoid admitting their ignorance, but that may cause problems later (struggling alone rather than asking for help, possibly leading to damage or injury, etc.). > there are such things as cultural memory and institutional memory. As a member of a group or society, you are expected to have a certain baseline amount of knowledge of that culture and history. How do you think the members of those groups have that knowledge? We have not (yet) evolved a genetic predisposition to grow, in utero, neuronal bundles encoding Unix shell prompt escape sequences. That's the point; everyone has all need to learn! Still, it's better to air and discuss such takeaways!
- inopinatus 6y agoThere’s a huge gulf between admitting you don’t know something, and being proud of it. Suggesting it was ever, or should be, somehow “shameful” to admit not knowing something, is an enemy of change and growth, and in everyday life becomes a recipe for perpetuating structural in-groups and all the systemic pathologies that go along with them. I am also grumpy old fart but I was raised in an engineering culture that was not afraid to ask “what’s a spline?”, and I don’t regret it.
- taviso 6y agoI'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.
- kragen 6y agoHmm, wasn't # the default erase character for teletype-era Unix? And @ the "kill" character (like modern ^U)? That would have made them a little annoying to type—not annoying enough to keep them from being used for cpp, though, and https://github.com/memnoth/unix-v6/blob/master/sys/dmr/tty.c#L30 https://github.com/memnoth/unix-v6/blob/master/sys/dmr/tty.c... suggests that you could type \#. (There was no "lnext" yet; it was just hardcoded to backslash.) The actual input erase handling is on https://github.com/memnoth/unix-v6/blob/master/sys/dmr/tty.c#L220 https://github.com/memnoth/unix-v6/blob/master/sys/dmr/tty.c.... The relevant struct member is declared in https://github.com/memnoth/unix-v6/blob/master/sys/tty.h#L35 https://github.com/memnoth/unix-v6/blob/master/sys/tty.h#L35 and initialized to CERASE in each tty driver, for example, https://github.com/memnoth/unix-v6/blob/master/sys/dmr/kl.c#L60 https://github.com/memnoth/unix-v6/blob/master/sys/dmr/kl.c#..., using the macro defined in https://github.com/memnoth/unix-v6/blob/master/sys/tty.h#L48 https://github.com/memnoth/unix-v6/blob/master/sys/tty.h#L48. So by default # was special, just to the kernel tty driver, not the shell.
- rcarmo 6y agoThat's a fair point. But in the 90s as a System V and SunOS user, I saw some discussions happen on Usenet, and by the time X was commonplace, the myth/rationale was commonplace.
- JdeBP 6y agoEven then, though, that was over a decade after the fact, and people were inventing explanations for things retroactively. Doug McIlroy has put the kibosh on this myth. * https://minnie.tuhs.org/pipermail/tuhs/2017-April/011286.html https://minnie.tuhs.org/pipermail/tuhs/2017-April/011286.htm...
- Aeolun 6y agoPotentially, but I can pretty much guarantee that someone working on any shell has run into this problem before, and then decided not to change the # because it was so damned convenient for preventing mispastes.
- gdavisson 6y agoThat implies you should put a space before the # in the root prompt, because it's not recognized as a comment delimiter if it's in the middle of a "word".
- tanelpoder 6y agoYep (author here), not pasting garbage into a terminal is the main point of this article. Partially, it's a rant against the way-too-trigger-happy "paste clipboard on right mouse click" terminals too. I decided to finally write this article, after seeing a yet another "mysterious" case of a missing binary in some Oracle database server. Linux/Bash defaults are ok, but historically (coming from traditional Unix background?), people who engineer environments at least in the Oracle database server world, configure their prompts to some "corporate standard". And sometimes they end up suffixing prompts by a nice-looking ">" character, leading to this problem. I've also seen someone set their root prompt to `root#>`. Since there's no space between the username and #, the "comment start" is not recognized and the redirection clobbering problem is still there.
- tener 6y agoWell, how about making it hard to do accidental input in the first place? If pasting is a problem the maybe make the actions necessary less possible to be triggered randomly?
- adrian_b 6y agoBecause of this problem, good terminals require confirmation before pasting any strings that contain suspicious characters, e.g. carriage returns.
- tinus_hn 6y agoI have seen a ‘good terminal’, apparently. Can you name one?
- andrey_utkin 6y agoXfce4-terminal prompts for confirmation when there's newline in the pasted contents.
- JdeBP 6y agoTwo examples: PuTTY and Windows Terminal both present confirmation dialogue boxes before pasting multiline content.
- gnramires 6y agoWhat about eliminating root usage? Could sudo be used here? Or perhaps every root command should need a confirmation prompt before execution.
- devmor 6y agoYeah this feels like more of a cautionary tale about proper privilege and directory management. Was there really a reason for OP to be inside the binary directory for the application in order to use it? Why was the binary writeable in the first place? If the binary was not normally writeable but the user was privileged, was it necessary to use a privileged user for this operation? You could probably create a pretty extensive list of failures that led to this issue. I think the author honed in on the one that made the most sense to himself and missed the forest for the tree.
- salawat 6y agoSo if someone grabs your hair during a fight, are you going to go bald the rest of your life? Just paste it somewhere besides a terminal. I swear, security people have run away with everyone's good sense. There's a point of diminishing returns where running with something that can cause a problem is completely practicable and justifiable. We don't need the nteenth "Shell that protects you from malicious paste" functionality. Just use root judiciously. If you can't be comfortable running as root and keeping yourself out of trouble, then you really don't know enough to use the machine safely. You must be 10% smarter than the piece of equipment. No amount of good natured or well-intentioned "protect you from yourself" coding will obviate you of the need to know what you are doing, the limitations of the machine, and the limitations of the program you're using. In fact, all it does is increase the bar for how many things worth of minutiae you have to account for.
- yawaramin 6y agoAFAIK Bourne shell (and Bash) defaults to $ for regular users. C shell (and tcsh) use %.
- suifbwish 6y agoAlso don’t shell script on the fly in a production server that has data of any sort you can’t restore from a backup. It’s one giant game of Russian roulette and eventually the human is going to screw up