logoalt Hacker News

jkercheryesterday at 1:23 PM6 repliesview on HN

Tangentially related. Don't ever put "." in your PATH. I used to do this to avoid typing the "./" to execute something in my current directory. BAD IDEA. It can turn a typo into a fork bomb. I took down a production server trying to save typing two characters.


Replies

marcosdumayyesterday at 5:29 PM

It used to be very common to "own" a unix system by adding a `ls` binary in some folder and waiting for an administrator to run it.

show 1 reply
mathfailureyesterday at 3:30 PM

I like to follow my own convention where I name files with shell scripts with an extension: .sh for POSIX-compatible scripts, .bash for scripts with bashisms or .zsh for scripts with zshisms.

If I ever wanted to achieve what you initially wanted to achieve - I could use something like

alias -s sh=sh

alias -s bash=bash

alias -s zsh=zsh

Just like I do bind .txt and .conf to 'less', .pdf to 'qpdf', .json to 'ijq', video formats to 'mpv' and so on.

zahlmanyesterday at 3:47 PM

Might I ask exactly what the typo was?

lanyard-textileyesterday at 3:03 PM

Elaborate?? "." has been at the end of my PATH for like 20 years.

show 1 reply
zelphirkaltyesterday at 3:03 PM

Why does this go wrong and in what situation?

show 3 replies
Kiboneuyesterday at 2:18 PM

lol. What a beautiful footgun — for such a tiny optimization.