14

I'm a little confused about the missing -e option from the bash manual. man bash

But it is working with a script shebang like : #!/bin/bash -e and of course it is defined in help set.

Why isn't it listed in the options in the bash manual ?

3
  • 1
    set is part of bash; all of its options are present in the bash manual. Sep 21, 2022 at 20:23
  • 1
    Obligatory see also: BashFAQ/105. Sep 22, 2022 at 20:21
  • Nowadays, the man pages are also available online (requires an Internet connection and a web browser of some sort), though if using a search engine to find them, it should be restricted to the site where they are known to exist, e.g. linux.die.net. Sample, for 'bash' Sep 27, 2022 at 11:30

2 Answers 2

22

It is implicitly mentioned at the start of the manual:

OPTIONS
All of the single-character shell options documented in the description of the set builtin command, including -o, can be used as options when the shell is invoked. [...]

You are then expected to look up the set builtin command further down in the manual, use help set in an interactive shell session (as you mention in the question), or access the longer reference manual in some appropriate way (e.g. by using the info bash set command, on systems where this works).

2
  • Or info bash set to get to the set documentation directly. info -n invoking bash for the section that contains your quote (section 6.1) with a hyperlink to the set section. Sep 21, 2022 at 6:17
  • Unlike the man page, the "Invoking Bash" section in the reference manual also mentions the short options in the invocation synopsis: bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o option] ...
    – ilkkachu
    Sep 21, 2022 at 18:33
9

It is in the bash(1) man page under set. On some systems, including Debian-based ones, you'll also find a bash-builtins(7) or even builtins(7) man page that covers only the builtin commands of that shell where the information may be easier to find.

...

  -e      Exit immediately if a pipeline (which may consist  of  a
          single  simple  command),  a list, or a compound command
          (see SHELL GRAMMAR above), exits with a non-zero status.
          The  shell  does  not  exit if the command that fails is
          part of the command list immediately following  a  while
          or  until  keyword, part of the test following the if or
          elif reserved words, part of any command executed  in  a
          &&  or || list except the command following the final &&
          or ||, any command in a pipeline but the last, or if the
          command's  return  value is being inverted with !.  If a
          compound command other than a subshell  returns  a  non-
          zero  status because a command failed while -e was being
          ignored, the shell does not exit.  A  trap  on  ERR,  if
          set,  is  executed  before the shell exits.  This option
          applies to the shell environment and each subshell envi‐
          ronment  separately  (see  COMMAND EXECUTION ENVIRONMENT
          above), and may cause subshells to exit before executing
          all the commands in the subshell.

          If  a  compound  command or shell function executes in a
          context where -e is being ignored, none of the  commands
          executed  within  the  compound command or function body
          will be affected by the -e setting, even if  -e  is  set
          and  a  command returns a failure status.  If a compound
          command or shell function sets -e while executing  in  a
          context  where -e is ignored, that setting will not have
          any effect until the compound  command  or  the  command
          containing the function call completes.

...

  errexit Same as -e.

...

1
  • 2
    Yes, but the description for the set builtin doesn't say that its options can be given to the shell as options when starting it. Many other builtins also take options but those can't be given as options to the shell itself (nor would they make sense). The fact that set options are different needs to be picked up from somewhere else. (e.g. under the "OPTIONS" section).
    – ilkkachu
    Sep 21, 2022 at 18:30

You must log in to answer this question.

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