Score:1

--version VS -version VS -v

it flag

I have been using linux for some time and whenever I need to find the version of some package, I need to either do --version or -version or -v.

python --version
npm -v

Also, I have noticed the case where -v is used, we can also use --version and -version.

FedKad avatar
cn flag
So what? Each tool has its own specific command line options which may not be identical for ***all*** the tools you are using..
cn flag
I don't see an actual question in your question.
guiverc avatar
cn flag
GNU standard options are with "--", unix default says "-" and BSD tend to prefer just have options (eg. `ps aux` without any hyphen needed)... Our system has programs from many different OSes that are all unix or unix-like. The reason is history (and whichever historical standard developers most use or prefer...)
spectre009 avatar
it flag
@guiverc thanks, so what I can understand is this that it mostly due to packages from different origins which follows different standards is the main reason behind this small discrepancy
guiverc avatar
cn flag
It's not the packages, but what's inside them (ie. the program author controls the defaults used by that program). You may already have guessed this, just making sure you don't realize it's the Ubuntu/debian packaging (deb/snap) that are involved... Maybe also refer https://xkcd.com/927/ & think history :)
Score:1
es flag

If you want to see the version of an installed package, why don't you simply ask the package manager?

sh@balrog:~$ dpkg -l python
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version        Architecture   Description
+++-===================-==============-==============-===========================================
ii  python              2.7.15~rc1-1   amd64          interactive high-level object-oriented lang
sh@balrog:~$ apt list python
Listing... Done
python/bionic,now 2.7.15~rc1-1 amd64 [installed]

If you don't know what package a program belongs to, again, ask the package manager:

sh@balrog:~$ dpkg -l xdpyinfo
dpkg-query: no packages found matching xdpyinfo

Duh... that must be in a different package...

sh@balrog:~$ dpkg -S $(which xdpyinfo)
x11-utils: /usr/bin/xdpyinfo
sh@balrog:~$ dpkg -l x11-utils
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version        Architecture   Description
+++-===================-==============-==============-===========================================
ii  x11-utils           7.7+3build1    amd64          X11 utilities
spectre009 avatar
it flag
I appreciate your descriptive answer and actually got to know a lot of new things, but this is a little off the topic.
HuHa avatar
es flag
Well, the sad truth is that Open Source developers will do whatever they think is best. You are right that command line options are often inconsistent; some best practices have become a de facto standard, i.e. `-v` and `--version`; but there is also that minority that thinks that `-version` is a good idea (mostly from the X11 world). Yes, that's inconsistent. That's one price to pay for all the diversity and choice the Open Source world gives us.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.