Live data from Hacker News

Suicide Linux

qntm.org

51–60 of 135 posts

Re: Suicide Linux

#51
post #40

I've added a counter (of successful commands in a row) to my bashrc. I've seen it as high as 120. function promptCommand() { LAST_STATUS=$? # Set title of window to dir, then add new line to prompt. PS1='\[\e]0;\w\a\]\n' if [ $LAST_STATUS -eq 0 ]; then ((successes++)) PS1+='\[\033[1;32m\][$successes]' else successes=0 PS1+='\[\033[1;31m\][0 $LAST_STATUS]' fi PS1+='\[\033[0;32m\] ' PS1+='\w $(date +%H:%M) \$ \[\033[0m…

Man, I hope you don't use grep very often (by default it uses exit code 1 when it doesn't find anything).

Just pipe the output through cat. By default, the "pipefail" option is not set, so

    echo foo | grep bar | cat
is successful. Of course, this works for any command.

Re: Suicide Linux

#52
post #6

a less destructive version of this is to install `sl` on your linux or mac.

I never type sl, but often type "gerp". I have an alias though.

My personal nemesis is "mroe". Also aliased. My wife, who drafts a lot of legal contracts, has a problem with "doe snot", which the spelling checker is more than happy with.

Re: Suicide Linux

#53
On Illumos rm -rf / does nothing. POSIX says that removing / has undefined behavior, so the obviously smart (useful, user-friendly, GOOD) thing to do is to do nothing, as that fits "undefined behavior".

Re: Suicide Linux

#54
post #6

a less destructive version of this is to install `sl` on your linux or mac.

Tip: If you ever trigger sl by mistake, and you're in a hurry, press Ctrl+Z instead of Ctrl+C (which doesn't work).

That seems like a bug in sl: it should signal(SIGTSTP, SIG_IGN) (or put the terminal in raw mode, better yet)

Re: Suicide Linux

#56

On Illumos rm -rf / does nothing. POSIX says that removing / has undefined behavior, so the obviously smart (useful, user-friendly, GOOD) thing to do is to do nothing, as that fits "undefined behavior".

That's quite funny... but ultimately futile. It doesn't say what happens if you say "DROP TABLE xyzWHERE...ohshit". (The bit is because you're used to doing that in your preferred SQL-DB editor.)

One should NEVER do anything non-scripted on a production system. ALWAYS enter it into a file and then do the "run-sql-from-a-file" command.

EDIT: Yes, I also realize that "rm -rf /" can theoretically happen if you have a bad variable substitution, but you MUST turn on the flags that cause your shell to error out instead of just substituting the empty string.

Re: Suicide Linux

#57
post #40

I've added a counter (of successful commands in a row) to my bashrc. I've seen it as high as 120. function promptCommand() { LAST_STATUS=$? # Set title of window to dir, then add new line to prompt. PS1='\[\e]0;\w\a\]\n' if [ $LAST_STATUS -eq 0 ]; then ((successes++)) PS1+='\[\033[1;32m\][$successes]' else successes=0 PS1+='\[\033[1;31m\][0 $LAST_STATUS]' fi PS1+='\[\033[0;32m\] ' PS1+='\w $(date +%H:%M) \$ \[\033[0m…

Man, I hope you don't use grep very often (by default it uses exit code 1 when it doesn't find anything).

If it didn't exist in the first place, then you had no business searching for it. You should have just known not to look. :)

Re: Suicide Linux

#58
post #38

Earlier quoted context omitted.

A friend of mine aliased `git status` `git statsu`; I, being lazier, chose `git st`. Any time saved I lost by not copying his other alias, `c = commit -amSTUFF`...

I must be lazier. I use `gitst` for `git status`. That is 1/6 shorter and IMO not harder to remember.

You all are doing way too much typing

gt git status ga git add gdd git diff to develop gdn same but name in only

Re: Suicide Linux

#59

In all seriousness, what if it's a machine that no one should ever really be running commands on? This could be an effective, albeit naive, way to discourage undesirables in the system.

That is the most absurd approach to access control I have ever heard... but I like it.

Re: Suicide Linux

#60
post #51
post #40

Earlier quoted context omitted.

Man, I hope you don't use grep very often (by default it uses exit code 1 when it doesn't find anything).

Just pipe the output through cat. By default, the "pipefail" option is not set, so echo foo | grep bar | cat is successful. Of course, this works for any command.

Alternatively and less wastefully:

    echo foo | grep bar || true
Post reply on HN