News for hackers. Stuff that matters.
Re:ZSH Aliases by franciscop on Tuesday May 26, 2020 @07:17AM (#23309682)
Okay this is pretty cool, I can set up so `.js` files are opened automatically with Node.js:

    $ alias -s js=node
    $ echo "console.log('Hello world')" > demo.js
    $ demo.js
    Hello world
Re:ZSH Aliases by georgyo on Tuesday May 26, 2020 @09:08AM (#23310636)
This seems like a good way to accidently run abitrary code downloaded from the internet.

I can see opening up in an editor as useful shortcut. But actually executing code without an executable bit seems a bit more dangerous.

Re:ZSH Aliases by trashburger on Tuesday May 26, 2020 @10:55AM (#23311931)
Worse, imagine if someone set their shell as the suffix alias for .sh, just to save time on their curl shell pipes... Oh the horror. Suffix aliases should come with a big caveat.
Re:ZSH Aliases by Spivak on Tuesday May 26, 2020 @09:22PM (#23318421)
Don't worry. I got you.

    alias -s sh='_c(){ curl -sk $1 | sudo bash };_c'
Wait. Improved.

    alias -s sh='_c(){ [[ -f $1 ]] && sudo bash $1 || curl -sk $1 | sudo bash };_c'
Re:ZSH Aliases by franciscop on Tuesday May 26, 2020 @09:43AM (#23310990)
Really? Last time I downloaded a .js file by accident was never if my memory doesn't fail me (.html I remember a couple). Even if I did, I normally use the UI to manage my files. The only time I might try to do something with the CLI and a JS file is exactly to run `node file.js`, and this is just a convenience.
Re:ZSH Aliases by sneak on Tuesday May 26, 2020 @09:13AM (#23310693)
You can do something similar with a shebang and chmod +x.
Re:ZSH Aliases by blauditore on Tuesday May 26, 2020 @10:15AM (#23311374)
...and even in a safe way.
Re:ZSH Aliases by Spivak on Tuesday May 26, 2020 @09:30PM (#23318482)
But then you need the cooperation of every file to include the shebang line. Muuch easier to just

    echo :js:E::0::/usr/bin/node: >/proc/sys/fs/binfmt_misc/register
Re:ZSH Aliases by thorstenhans on Tuesday May 26, 2020 @07:22AM (#23309716)
Yes suffix aliases are super useful