Read more

Bash: How to only do things in interactive shells

Thomas Eisenbarth
December 06, 2013Software engineer at makandra GmbH

When you print something from within your .bashrc file you will run into trouble when copying something onto your machine using scp for example.

Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

This is because the output from your .bashrc interferes with scp. The solution is to decide whether the bash shell is started interactively (you start a terminal on your screen) or not (scp).

if [ ! -z "$PS1" ]; then
  # This happens in interactive shells only and does not interfere with scp.
  echo "Learn!"
fi
Posted by Thomas Eisenbarth to makandra dev (2013-12-06 11:05)