From 71016aa3548e9d59b4c7b6635b1f485b4e48d333 Mon Sep 17 00:00:00 2001
From: Andres Montano <andres.montano@tecnalia.com>
Date: Thu, 9 Jun 2022 12:53:40 +0200
Subject: [PATCH] Fix issues with docker and sources

---
 dockerfiles/DevenvMelodic.Dockerfile |  7 ++++---
 dotfiles/ros.bash                    | 17 +++++++++--------
 dotfiles/system.bash                 | 25 +++++++++++++++++--------
 3 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/dockerfiles/DevenvMelodic.Dockerfile b/dockerfiles/DevenvMelodic.Dockerfile
index ff8f4ed..ca70dd8 100644
--- a/dockerfiles/DevenvMelodic.Dockerfile
+++ b/dockerfiles/DevenvMelodic.Dockerfile
@@ -52,7 +52,7 @@ RUN apt-get -y install --no-install-recommends \
 # Configure system to look for debian packages in the Artifactory repository
 ARG USER_API_KEY_ARTIFACTS_TECNALIA
 RUN sh -c "echo \
-	'deb https://${USER_API_KEY_ARTIFACTS_TECNALIA}@artifact.tecnalia.com/artifactory/tecnalia-robotics-debian xenial main' \
+    'deb https://${USER_API_KEY_ARTIFACTS_TECNALIA}@artifact.tecnalia.com/artifactory/tecnalia-robotics-debian xenial main' \
     >> /etc/apt/sources.list.d/tecnalia.list"
 
 # Import the key in order to be able to use the packages from the repository
@@ -126,8 +126,8 @@ RUN apt-get install -y \
     ros-melodic-abb-driver \
     libqd-dev \
     ros-melodic-swri-profiler \
-	ros-melodic-force-torque-sensor-controller \
-	ros-melodic-effort-controllers
+    ros-melodic-force-torque-sensor-controller \
+    ros-melodic-effort-controllers
 
 RUN apt-get install -y \
     libdouble-conversion-dev
@@ -206,6 +206,7 @@ RUN chmod a+x /ros_entrypoint.sh
 
 ENTRYPOINT ["/ros_entrypoint.sh"]
 CMD ["zsh"]
+ENV SHELL /usr/bin/zsh
 
 # Switch back to dialog for any ad-hoc use of apt-get
 ENV DEBIAN_FRONTEND=
diff --git a/dotfiles/ros.bash b/dotfiles/ros.bash
index 539f229..3d343cf 100644
--- a/dotfiles/ros.bash
+++ b/dotfiles/ros.bash
@@ -2,9 +2,9 @@
 # ROS
 ###################################################################
 
-export ROS_DISTRO=noetic
+if [ -z $ROS_DISTRO ]; then export ROS_DISTRO=noetic; fi
 
-ext=$(basename ${SHELL})
+if [ -z $SHELL ]; then echo "SHELL not set"; else ext=$(basename ${SHELL}); fi
 
 # Source rosmon
 function smon(){
@@ -27,18 +27,19 @@ function cbclean(){
 }
 
 function cib(){
-    catkin init && catkin config --extend /opt/ros/${ROS_DISTRO} && catkin build	
+    catkin init && catkin config --extend /opt/ros/${ROS_DISTRO} && catkin build
 }
 
 # If terminal starts in a ws, auto source it (useful for vscode)
 pwd_bck=${PWD}
 cropped=${PWD#${HOME}/ros/${ROS_DISTRO}/}
 WS_name=${cropped%%/*}
-WS_path=${HOME}/ros/${ROS_DISTRO}/${WS_name} 
+WS_path=${HOME}/ros/${ROS_DISTRO}/${WS_name}
 FILE=${WS_path}/devel/setup.${ext}
 if [[ -f $FILE ]]; then
-   cd ${WS_path}
-   source $FILE
-   smon
-   cd ${pwd_bck}
+  cd ${WS_path}
+  source $FILE
+  cd ${pwd_bck}
+else
+  source /opt/ros/${ROS_DISTRO}/setup.${ext}
 fi
diff --git a/dotfiles/system.bash b/dotfiles/system.bash
index 381988f..50768e6 100644
--- a/dotfiles/system.bash
+++ b/dotfiles/system.bash
@@ -1,10 +1,19 @@
-# Directories
-alias ll='lsd -lh --group-dirs=first'
-alias la='lsd -a --group-dirs=first'
-alias l='lsd --group-dirs=first'
-alias lla='lsd -lha --group-dirs=first'
-alias ls='lsd --group-dirs=first'
-# Files
-alias cat='bat'
+
+if command -v lsd &> /dev/null
+then
+    # Directories
+    alias ll='lsd -lh --group-dirs=first'
+    alias la='lsd -a --group-dirs=first'
+    alias l='lsd --group-dirs=first'
+    alias lla='lsd -lha --group-dirs=first'
+    alias ls='lsd --group-dirs=first'
+fi
+
+if command -v bat &> /dev/null
+then
+    # Files
+    alias cat='bat'
+fi
+
 # Python
 alias ipy='ipython'
\ No newline at end of file
-- 
GitLab