A few times I mistook bash -v or bash --v to represent bash --version which they do not, as of Bash 4.3.48(1).

From man bash, bash -v is equivalent to bash --verbose; although it returns a large output (allegedly some bashrc files, maybe more); I think it just starts a child session.

bash --v outputs much less, mainly bash: --v: invalid option.

I planned to ask if any of the two could be problematic in an all-default bash but I see no evidence for that and assumes Bash newbies shouldn't be stressed by these.

My question

I did misunderstood from man bash, what's the meaning of bash -v varname.

What is the meaning of starting a new bash session with a seemingly undefined variable, or it means to start it with also printing the value of an exported variable[1]?

Notes for newcomers:

  1. An exported variable is any variable inherited from one shell session to another (say from session 0 to session 1).
  • I just read ½ of you post before realising that you was just telling us something that is not part of the question. Then I lost interest (-1). – ctrl-alt-delor Apr 14 '18 at 17:24
  • I know that, I felt it's not good to delete that as it can help people find this question in Google and have some background. – user9303970 Apr 14 '18 at 17:27
  • If you feel it is needed to give background info, then put it at the end. (Start with what is most important). – ctrl-alt-delor Apr 14 '18 at 17:29
  • I shortened greatly. I don't agree that one "musn't" start with background info; I think it'll be better sometimes. – user9303970 Apr 14 '18 at 17:37

You are confusing two things.

  1. Starting bash as bash -v will start a bash shell in which the set -v (set -o verbose) shell option is set. It is equivalent to bash -o verbose and to bash --verbose (one of the few shell options that has a long option equivalent). One is able to set any of the abefhkmnptuvxBCHP options by using their single letters or by using -o and their long name directly when starting bash, e.g. bash -x and bash -o xtrace.

  2. The -v varname comes from, I assume, the description of the built-in test command which is able to test whether a variable is set with test -v varname or [ -v varname ].

See the bash manual or help set and help test in bash.

The long options for bash can not be abbreviated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.