I've been reading through the bash man page, and reading through scripts on my system (CentOS 6.7), looking up things in the bash man page as I go. It's a great exercise; I learned, for instance, how /etc/profile checks if the -i option is set when there are actually no options in the positional parameters (so getopts wouldn't work).

However, the following line has me totally stumped; I can't find anything in the bash man page that explains what it could be doing:

LESSOPEN="${LESSOPEN-||/usr/bin/lesspipe.sh %s}"

(This is a portion of a line in /etc/profile.d/less.sh.)

Am I just missing something in man bash?

Yes, I was missing something in man bash: Above the explanation for ${parameter:-word}, it says Omitting the colon results in a test only for a parameter that is unset. This was the missing piece. (And is not covered in the "possible duplicate" question, by the way.)

The fact that the default value being assigned was the name of a script after an "or" operator only added to my confusion! :)


1 Answer 1


This is not bash specific but it existed in the Bourne Shell since 1976.

Check the Bourne Shell man page:


Check section Parameter Substitution currently starting on page 7.

${parameter-word}        Use Default Values. If parameter is unset,
                         the  expansion  of  word is substituted;
                         otherwise,  the  value of parameter is substituted.

For a complete overview, there is:

                     | parameter nonnull | parameter null  | parameter unset
  ${parameter:-word} | subst. parameter  | subst. word     | subst. word
  ${parameter-word}  | subst. parameter  | subst. null     | subst. word
  ${parameter:=word} | subst. parameter  | assign word     | assign word
  ${parameter=word}  | subst. parameter  | subst. null     | assign word
  ${parameter:?word} | subst. parameter  | error, exit     | error, exit
  ${parameter?word}  | subst. parameter  | subst. null     | error, exit
  ${parameter:+word} | subst. word       | subst. null     | subst. null
  ${parameter+word}  | subst. word       | subst. word     | subst. null
  • Aha. man bash covers the :- usage, but doesn't document the - usage. And I see from the above that they are different. Good to know. So then, the rest of the line is used as just a literal string (if it's used at all)—i.e. '||/usr/bin/lesspipe.sh %s' with no expansions of any kind?
    – Wildcard
    Oct 16, 2015 at 12:39
  • Whoops, it IS covered after all! Omitting the colon results in a test only for a parameter that is unset. Thanks very much!
    – Wildcard
    Oct 16, 2015 at 12:42
  • 1
    The table above was taken from the POSIX standard. The original Bourne Shell man page did not document the difference between :- and - very well although it is hidden in some sentence. It seems that bash copied from the original Bourne Shell man page and introduced a similar hard to understand text.
    – schily
    Oct 16, 2015 at 12:43
  • Yes, you found the sentence taken from the old Bourne Shell man page!
    – schily
    Oct 16, 2015 at 12:44
  • 1
    BTW: If I remember a recent talk from Steven Bourne correctly, the support for the additional colon was added around 1979.
    – schily
    Oct 16, 2015 at 12:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .