3 ms·
Some of these are pretty cool. One piece of experience I'd like to offer: Don't ever use ">" in your prompts, particularly as root. A coworker had spent sever
by iigs 17y ago
Some of these are pretty cool. One piece of experience I'd like to offer:
Don't ever use ">" in your prompts, particularly as root.
A coworker had spent several days working on* an important script with a tight deadline that was almost upon him, and with a quick slip of the right mouse button, pasted what he had selected before (several lines of window scrollback) into the window to be executed, including:
/tmp/foo> ./blah.pl
and just like that, blah.pl ended up zero length. We hard killed the machine and scanned the disk for the contents of the script and recovered most of it, but had the specifics been different we could have been a lot less lucky.
For this reason it's probably also a good idea to avoid question marks, asterisks, and anything else the shell could expand, as well.
* While the story plays just as well, it's not meant to be an argument for source control. It could have just as easily been full paths to system binaries and have ended up trashing the system.
- whimsy 17y agoIf you're particularly worried about this sort of thing, you can wrap your prompt in : and ; i.e. : user@host $ ; Source is http://www.faqs.org/docs/Linux-HOWTO/Bash-Prompt-HOWTO.html#AEN784 http://www.faqs.org/docs/Linux-HOWTO/Bash-Prompt-HOWTO.html#...
- there 17y agoor use something like 'set noclobber' (at least in tcsh) jcs@smug:~% echo asdf > file jcs@smug:~% echo fdsa > file file: File exists. jcs@smug:~% echo fdsa >! file jcs@smug:~% this has saved me quite a few times when accidently typing > instead of >> or similar.
- makecheck 17y agoI'd argue that this isn't really a prompt problem, though. For example, when using typical Unix terminals, I refuse to mouse copy/paste when logged in as root (whether or not the prompt is nearby), because it's too easy to make a mistake and the consequences are severe. Similarly, I refuse to rely on any cute shell tricks like "!" to pull history items when logged in as root. Sacrifice convenience to guarantee safety. I also prefer to use my Mac terminal (MacTelnet), which will trap multi-line pastes and offer options to paste as-is, paste as one line, or cancel the operation. This has saved me more than once.
- ggchappell 17y agoPerhaps the real lesson to be learned here is don't ever login as root (?). (Certainly there are a few things I don't know about administering large groups of machines. However, I've been running my own personal Linux boxes for a while. And the last time I logged in as root was a bit over 9 years ago.)