Why does bash with "here documents" redirection start as interactive?
8
votes
1
answer
892
views
I found the following in
man bash
as a definition of interactive shell:
> An interactive shell is one started without non-option arguments
> (unless -s is specified) and without the -c option whose standard
> input and error are both connected to terminals (as determined by
> isatty(3)), or one started with the -i option. PS1 is set and $-
> includes i if bash is interactive, allowing a shell script or a
> startup file to test this state.
So, interactive shell is the one that:
1. doesn't have non-option arguments (unless -s
is specified), doesn't have -c
option and whose standard input and error are both connected to terminal; or
2. has -i
option
I wrote the following example:
```
bash This type of redirection instructs the shell to read input from the
> current source until a line containing only delimiter (with no
> trailing blanks) is seen. **All of the lines read up to that point
> are then used as the standard input** (or file descriptor n if n is
> specified) for a command.
It says that standard input is all lines read up to the delimiter (I assume that they are then passed to the command by redirecting the command's standard input to a pipe or something like that). Therefore, standard input is not (connected to) a terminal.
Why is this happening? Why is bash interactive in this case?
Asked by Yakog
(517 rep)
Feb 25, 2025, 09:12 PM
Last activity: Feb 25, 2025, 10:34 PM
Last activity: Feb 25, 2025, 10:34 PM