Skip to content

template/profile: Require interactive shell #1325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2019

Conversation

rico-chet
Copy link
Contributor

Bash is run either in interactive mode (e.g. in a terminal) or
non-interactive mode (e.g. on an SSH server handling an SCP request). In
the latter example, any output performed by bash-it's actions will be
interpreted as SCP reply on the client side, typically leading to failed
transfers. This is a well-known limitation of the SCP:
https://bugzilla.redhat.com/show_bug.cgi?id=20527.

In bash's own bashrc example, the first lines of code query for the mode
and return early if it's non-interactive:
http://git.savannah.gnu.org/cgit/bash.git/tree/examples/startup-files/bashrc?h=bash-5.0#n1.
This practice is adopted by Linux distributions (e.g. Ubuntu) and
probably other systems.

Current mode can be queried as described here:
https://www.gnu.org/software/bash/manual/html_node/Is-this-Shell-Interactive_003f.html.

Copy the according lines from Debian stretch's default .bashrc (as found
in https://packages.debian.org/stretch/bash under /etc/skel/.bashrc) to
the bash-it profile template to disable bash-it for non-interactive
shells.

As a side effect, this change makes SCP faster since the server doesn't
need to run any bash-it code in context of SCP handling.

Bash is run either in interactive mode (e.g. in a terminal) or
non-interactive mode (e.g. on an SSH server handling an SCP request). In
the latter example, any output performed by bash-it's actions will be
interpreted as SCP reply on the client side, typically leading to failed
transfers. This is a well-known limitation of the SCP:
https://bugzilla.redhat.com/show_bug.cgi?id=20527.

In bash's own bashrc example, the first lines of code query for the mode
and return early if it's non-interactive:
http://git.savannah.gnu.org/cgit/bash.git/tree/examples/startup-files/bashrc?h=bash-5.0#n1.
This practice is adopted by Linux distributions (e.g. Ubuntu) and
probably other systems.

Current mode can be queried as described here:
https://www.gnu.org/software/bash/manual/html_node/Is-this-Shell-Interactive_003f.html.

Copy the according lines from Debian stretch's default .bashrc (as found
in https://packages.debian.org/stretch/bash under /etc/skel/.bashrc) to
the bash-it profile template to disable bash-it for non-interactive
shells.

As a side effect, this change makes SCP faster since the server doesn't
need to run any bash-it code in context of SCP handling.
@rico-chet
Copy link
Contributor Author

rico-chet commented Feb 4, 2019

As to why the ~/.bashrc is run in the context of SCP handling, refer to
https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-by-remote-shell-daemon

Edit: and here's a nice explanation of the whole picture: https://unix.stackexchange.com/a/257613

@rico-chet
Copy link
Contributor Author

This probably fixes #220 #530 #535 #611 #706 #717 #1032

@nwinkler nwinkler merged commit f02dab4 into Bash-it:master Feb 5, 2019
@nwinkler
Copy link
Member

nwinkler commented Feb 5, 2019

This is great - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants