News for hackers. Stuff that matters.
Re:Abbrev: A Hidden Ruby Gem by zoky on Friday August 18, 2023 @09:26AM (#37175299)
I mean, okay… but… A lot of command line software already works that way, where you only need to type the minimum number of characters required to disambiguate a command, and as far as I know nobody has died yet as a result.
Re:Abbrev: A Hidden Ruby Gem by digitalsushi on Friday August 18, 2023 @09:35AM (#37175423)
Abbreviated commands are fine for manual interaction, but a good engineer puts the full commands into source code for discoverability and specificity. If I saw a teammate putting abbreviated commands into source code, I would ask them to change it to the full commands, and I would feel entitled to.

Also, how would we know if no one has died from this? The practice of abbreviating commands literally makes forensics more difficult to accomplish, making it harder to know.

Re:Abbrev: A Hidden Ruby Gem by hk__2 on Friday August 18, 2023 @10:30AM (#37176173)
> A lot of command line software already works that way, where you only need to type the minimum number of characters required to disambiguate a command, and as far as I know nobody has died yet as a result.

Do you have an example? None of the command-line tools I use every day work that way. The usual workflow is 1- type a couple characters; 2- press <tab> to complete. The second step is crucial because it ensures you run the right command.

Re:Abbrev: A Hidden Ruby Gem by vulcan01 on Friday August 18, 2023 @11:16AM (#37176839)
GDB is one software I use a lot that has this feature. You can abbreviate break, print, delete, and others.

For conflicts (does 'd' refer to delete or disable?) the more commonly used command is usually what the abbreviation will expand to (so GDB accepts 'd' for "delete").

Re:Abbrev: A Hidden Ruby Gem by MatmaRex on Friday August 18, 2023 @12:29PM (#37178065)
npm and gem behave like this, although I don't know if they use this exact method to figure out the abbreviations.

git has something similar, although it's disabled by default (help.autocorrect option).

Re:Abbrev: A Hidden Ruby Gem by hk__2 on Saturday August 19, 2023 @08:46AM (#37188217)
Thanks.

> npm and gem behave like this

No, `npm` has a couple aliases like "i" for "install", but you can’t use "in", "ins", "insta", etc. It has "view" and "version" but "v" is an alias for "view".

`gem` does work like this (#TIL), although it has some hard-coded aliases: while its help page says "Commands may be abbreviated, so long as they are unambiguous", `gem i` works as `gem install` even if there’s a command "info". If you try `gem in`, it does complain that it’s ambiguous.