Bash -C "Source ~/. Profile" Doesn't Source ~/. Profile

Here's some output from inside a Docker container (running Ubuntu 18.04) which seems to be acting up.

# source ~/.profile
net.ipv4.ipfrag_high_thresh = 134217728
net.core.rmem_default = 10485760
sourcing /opt/ros/foxy/install/setup.bash
ROS_ROOT   /opt/ros/foxy
ROS_DISTRO foxy
# bash -c "source ~/.profile"
# /bin/bash -c "source /root/.profile"
# 

The output from the first command is something I expect from the following commands. Feels like I'm missing something obvious here. For context, I need /bin/bash -c "source /root/.profile" to work because I don't want to have to enter the Docker container in order to run my commands, and I want to run the stuff in .bashrc prior to running them. Where am I going wrong?

5

1 Answer

In .bashrc:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

Following command works fine:

/bin/bash -ic "source ~/.bashrc"
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest