News for hackers. Stuff that matters.
Re:Use long flags when scripting (2013) by gkop on Friday September 18, 2020 @02:05PM (#24519964)
Long flags aren’t just for readability, they also add entropy which contributes defensiveness against typos.
Re:Use long flags when scripting (2013) by UI_at_80x24 on Friday September 18, 2020 @04:59PM (#24521830)
And to add to your point, in my experience I've had "long-lived" scripts that the flags change meaning over the years. This is extremely rare on base-level installs, but frighteningly more common on the inhouse-programs I've had to deal with.

The long flags are less likely to be changed over time. The script will usually fail gracefully and I don't also need to relearn what I was thinking 25 years ago when I first did it. (long flags are like in-command comments too)

And as others have pointed out -v(ersion) or -v(erbose) can happen too.

Re:Use long flags when scripting (2013) by MaxBarraclough on Friday September 18, 2020 @03:23PM (#24520871)
Related to this, they're less likely to do something unexpected.

Many programs use -v as a short flag for --version, but some (such as curl) use it as short for --verbose

Probably something you'd catch pretty quickly, but still.

Re:Use long flags when scripting (2013) by ben509 on Friday September 18, 2020 @06:28PM (#24522473)
The worst (well known) offender is grep -v meaning grep --invert-match just for the sheer bafflement of "verbose" now hiding what you were looking for.
Re:Use long flags when scripting (2013) by u801e on Saturday September 19, 2020 @10:42PM (#24531596)
That actually comes from ed and vi. The g command would search for a line that matches a given regular expression and run the following command on that line. The v command was the inverse (search for lines that don't match the given regular expression).

The default command was to just print the line. Hence the name grep

g/re/p

Re:Use long flags when scripting (2013) by EE84M3i on Saturday September 19, 2020 @02:22AM (#24525584)
Wow, that's funny, I normally expect '-v' to be verbose, but maybe I just use a lot of `tar` and `curl`!
Re:Use long flags when scripting (2013) by mjochim on Saturday September 19, 2020 @07:48AM (#24526786)
Or maybe cp, or rm, or rsync, or mount, or wget, or netcat (both gnu and bsd) ... it’s really pretty reasonable to expect -v to mean verbose ;-).
Re:Use long flags when scripting (2013) by dpcx on Friday September 18, 2020 @04:38PM (#24521663)
As does Python, which drives me crazy. -V is version on Python.
Re:Use long flags when scripting (2013) by MaxBarraclough on Friday September 18, 2020 @04:52PM (#24521778)
Very annoying. Java HotSpot uses -version, rather than --version, which is even worse. Don't mess with the standard long-form flag!
Re:Use long flags when scripting (2013) by LukeShu on Friday September 18, 2020 @05:28PM (#24522057)
To be fair, the JVM predates GNU-style --long flags being "standard". Lots of older programs use "X11-style" -long flags (that many pre-X11 programs used, like `find`).
Re:Use long flags when scripting (2013) by tannhaeuser on Saturday September 19, 2020 @03:34AM (#24525843)
Long flags are a GNUism, not a "standard" by any means. The closest that comes to a standard in this space are POSIX utility conventions [1].

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...

Re:Use long flags when scripting (2013) by hackerm0nkey on Friday September 18, 2020 @05:17PM (#24521960)
I get it wrong every damn time. 16 years and counting.
Re:Use long flags when scripting (2013) by iforgotpassword on Saturday September 19, 2020 @03:25AM (#24525818)
Same! Somehow I also start confusing this with somewhat related tools like gcc. It's rare enough that I need to query these that it's all blurry in my memory again by next time. "huh I guess gcc was that goofy one with just one dash.." Nope.
Re:Use long flags when scripting (2013) by nostoc on Friday September 18, 2020 @11:57PM (#24524888)
There's so much variation in flags for version, I've taken the habit of always using the long `--version` flag.
Re:Use long flags when scripting (2013) by jjgreen on Friday September 18, 2020 @07:27PM (#24522864)
... and it wrote the version to stderr up to 3.3, the stdout from 3.4; very convenient if you need to switch on version (which you do).
Re:Use long flags when scripting (2013) by fuzzer37 on Friday September 18, 2020 @04:26PM (#24521535)
But also contributes to the heat death of the universe.
Re:Use long flags when scripting (2013) by edoceo on Friday September 18, 2020 @04:28PM (#24521567)
what doesn't?
Re:Use long flags when scripting (2013) by ben509 on Friday September 18, 2020 @06:33PM (#24522505)
Nah, it's already happened, and we all pop up every 10^10^100 eons to pretend this is all real.
Re:Use long flags when scripting (2013) by arthurcolle on Friday September 18, 2020 @08:18PM (#24523295)
Shhh don't share meta content with the NPCs...