Invalid export in shell script

Wrote a shell script:

#!/bin/bash
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic

The first line is source and the second line is export.
Running exportthe two lines found has no effect.

The reason is that my running method is ./my_setup.sh, and the running result is effective in the sub-shell, not the parent shell.

Reference article: Linux shell script export is invalid , just modify it source ./my_setup.bash.

Supongo que te gusta

Origin blog.csdn.net/weixin_45910027/article/details/132149719
Recomendado
Clasificación