Can anyone tell me about the -t option when invoking bash?

I found the following handy command to use a lightweight terminal window as an application launcher

urxvt -geometry 80x3 -name 'bashrun' -e sh -c "/bin/bash -i -t"

Through a little investigation of its behavior, I see that the -t essentially makes bash exit after executing one command, but I am curious if there is any more to that specific -t option. I can't actually find any documentation about it, and I've looked through the following docs:

I find it odd that -t is not as clearly laid out as the rest of the options.

  • Side note: bash --help actually tells you to use help set to see descriptions for short options. Oct 28, 2015 at 1:14

3 Answers 3


You are right that it is amazingly poorly documented. What documentation that there is is quite simple:

-t      Exit after reading and executing one command.

The bash source code is available here. I looked at version 4.2. The short flags handled by bash are listed in flags.c and in there is the relevant line:

{ 't', &just_one_command },

So, -t on the command line sets the variable just_one_command. This variable is used in just one place: it occurs in an if condition at the end of a loop in eval.c:

  if (just_one_command)
    EOF_Reached = EOF;

In other words, if the -t flag is given, then, after the first command is executed, the end-of-file condition is signaled and bash exits.


From eval.c, command line execution in bash appears to be controlled by the function reader_loop:

reader_loop ()
  int our_indirection_level;
  COMMAND * volatile current_command;
  current_command = (COMMAND *)NULL;
  our_indirection_level = ++indirection_level;
  while (EOF_Reached == 0)
      int code;
      code = setjmp_nosigs (top_level);

      [ ... Much code removed ... ]

      if (just_one_command)
        EOF_Reached = EOF;
  return (last_command_exit_value);

The loop inside reader_loop continues until it receives the signal EOF_Reached. The sole effect of the -t option is to set this flag at the end of loop which assures that the loop is executed only once.

  • 1
    Thanks all for the responses. Im marking @John1024's answer since it includes the original source code for the option. It seems I needed to look in help set for the actual documenation Mar 16, 2014 at 18:10
  • 1
    @HariSeldon if you should come back, please use the tick mark to accept this answer.
    – roaima
    Jul 4, 2020 at 15:45

Using the bash builtin help, i.e. by saying help set, you'd find:

  -t  Exit after reading and executing one command.

Since bash parses a line at a time, you might have multiple commands separated by ; on the same line and those would execute. For example, the following:

set -t; echo Do something; echo do more; echo and more
echo no more

would produce

Do something
do more
and more

as the output. On the other hand, the following:

set -t
echo Do something
echo do more
echo and more
echo no more

would not produce any output.

You could look for the documentation in the info page. Say:

info bash "Shell Builtin Commands"

Navigate to * Bourne Shell Builtins:: and search for help.

  • 1
    help set seems to be what i needed. Where is it listed that help set is something to look for? I'm not being snide, i am genuinely curious. Looking through man bash again, I am not seeing any mention of it. Mar 16, 2014 at 18:14
  • 1
    @HariSeldon I usually refer to info pages instead of manuals for those are usually more detailed. Please refer to the edit above for finding help on help.
    – devnull
    Mar 16, 2014 at 18:19

It is explained in the man page, just difficult to find.

The options not mentioned in the "OPTIONS" block at the beginning are options for set which can be given as options to bash, too:

The options can also be specified as arguments to an invocation of the shell.

-t      Exit after reading and executing one command.

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.