9

So, I needed to figure out how "exec" works. However, doing man exec brings me to a 99% useless man page describing what bash builtins are. It of course also does this with many other man pages such as cd, chdir, etc..

How can I look up the manual page for the actual utility I'm interested in, not the builtins man page?

My OS is Mac OSX, but I've had this on other operating systems as well

1
  • 1
    That man page is not about bash. Are you interested in bash's exec specifically? Dec 22, 2015 at 21:56

1 Answer 1

10

Getting documentation for shell builtins can be done using the command help. For example:

$ help exec
exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
    Replace the shell with the given command.

    Execute COMMAND, replacing this shell with the specified program.
    ARGUMENTS become the arguments to COMMAND.  If COMMAND is not specified,
    any redirections take effect in the current shell.

    Options:
      -a name   pass NAME as the zeroth argument to COMMAND
      -c                execute COMMAND with an empty environment
      -l                place a dash in the zeroth argument to COMMAND

    If the command cannot be executed, a non-interactive shell exits, unless
    the shell option `execfail' is set.

    Exit Status:
    Returns success unless COMMAND is not found or a redirection error occurs.

Otherwise, one could run man bash and then search within this (perhaps by typing /\bexec\b, in this case, assuming a less-like pager).

4
  • heh, I wish the "help exec" documentation on OSX was that well formatted. For me it's a single command line exec [-a]... and then a wall of text
    – Earlz
    Dec 22, 2015 at 21:57
  • That's presumably because OS X comes with an older version of bash; you could use Homebrew to install bash 4.
    – dhag
    Dec 22, 2015 at 22:02
  • @dhag Could be that the terminal is not set up properly. On unix the shell and terminal are separate processes (and executables). Dec 22, 2015 at 23:33
  • @richard: It could be a terminal issue, but I actually tried on OS X with the built-in bash, and saw the kind of result that Earlz described, while a newer, brew-installed bash shows the output that I quoted.
    – dhag
    Dec 23, 2015 at 13:25

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