News for hackers. Stuff that matters.
Re:Path Isn't Real on Linux by AlienRobot on Tuesday April 29, 2025 @10:48PM (#43840729)
Username checks out.

I think one of the most surprising things I learned about bash is that you can do this:

    touch ./-rf
    rm *
And now you have rm -rf'd. :)
Re:Path Isn't Real on Linux by teo_zero on Wednesday April 30, 2025 @02:10AM (#43841767)
We should use "--" more, but who has all this time to waste? :)
Re:Path Isn't Real on Linux by PhilipRoman on Wednesday April 30, 2025 @07:41AM (#43843814)
Indeed, always prefer ./* to *

I often wish there was a convenient way of doing such an operation in the shell: if path start with "/", leave it, otherwise prepend "./"

Re:Path Isn't Real on Linux by quotemstr on Wednesday April 30, 2025 @08:12AM (#43844108)
> I often wish there was a convenient way of doing such an operation in the shell: if path start with "/", leave it, otherwise prepend "./"

Both bash and zsh have enough functionality exposed via shell functions and variables for you to define a keybinding that does exactly this, interactively. Good idea.

Did you mean an interactive command? Or something else?

Re:Path Isn't Real on Linux by PhilipRoman on Wednesday April 30, 2025 @08:51AM (#43844488)
I meant non-interactive, for use in scripts which take user input. We already have "--" for end of options, but the support for it is not universal and even with that some programs will interpret certain strings in a special way. On the other hand, prepending the dot-slash should work for any program or argument passing style.
Re:Path Isn't Real on Linux by just6979 on Wednesday April 30, 2025 @12:45PM (#43847782)
Prepend for all paths on a command line? Or just for the executable?

For all paths it could be dangerous and should very probably not be done. But for executables it's less dangerous and can easily be done by putting '.' into $PATH.