Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#20717 - [bash] ~/.bashrc can't know when bash is in interactive mode
Attached to Project:
Arch Linux
Opened by maxi jac (maxi_jac) - Thursday, 02 September 2010, 08:51 GMT
Last edited by Allan McRae (Allan) - Wednesday, 02 February 2011, 05:30 GMT
Opened by maxi jac (maxi_jac) - Thursday, 02 September 2010, 08:51 GMT
Last edited by Allan McRae (Allan) - Wednesday, 02 February 2011, 05:30 GMT
|
DetailsHi,
Description: ~/.bash_profile sources ~/.bashrc. bashrc then tries to see when bash is in interactive session by using : # Check for an interactive session [ -z "$PS1" ] && return But it does not work because in both interactive and login bash shells, /etc/profile reads (indirectly) /etc/bash.bashrc that sets the PS1 variable. In both ways, PS1 is then set. I don't know if it really matters but I wanted to let you know about that. Maybe the way ~/.bashrc finds out if it's an interactive shell should be changed. |
This task depends upon
Closed by Allan McRae (Allan)
Wednesday, 02 February 2011, 05:30 GMT
Reason for closing: Works for me
Wednesday, 02 February 2011, 05:30 GMT
Reason for closing: Works for me
#!/bin/bash
echo "PS1: $PS1"
[ -z "$PS1" ] && echo "not interactive"
and output is:
PS1:
not interactive
If I run [ -z "$PS1" ] && echo "not interactive" in a terminal, there is no output. So I think the test works fine.
in .bashrc I added :
# Check for an interactive session
[ -z "$PS1" ] && return
echo "interactive"
$ bash -l
interactive
$ bash -i
interactive
What do you think of this test case ?
See https://bbs.archlinux.org/viewtopic.php?id=45038
> interactive
Isn't this expected... A login shell is not necessarily non-interactive. Test using a script.