@@ -15,7 +15,7 @@ CUROBO_VERSION_TAG='sim-6.1.0-curobo'
1515# Resolve TORCH_CUDA_ARCH_LIST for the cuRobo build. Honour an explicit override if set, else
1616# auto-detect the host GPU's compute capability via nvidia-smi (e.g. "12.0" -> "12.0+PTX").
1717detect_cuda_arch () {
18- if [ -n " ${TORCH_CUDA_ARCH_LIST:- } " ]; then
18+ if [[ -n " ${TORCH_CUDA_ARCH_LIST:- } " ] ]; then
1919 echo " ${TORCH_CUDA_ARCH_LIST} "
2020 return 0
2121 fi
@@ -75,12 +75,13 @@ while getopts ":d:crRvh" OPTION; do
7575 ;;
7676 \? ) echo " Invalid option: -$OPTARG " >&2 ; exit 1 ;;
7777 :) echo " Option -$OPTARG requires an argument." >&2 ; exit 1 ;;
78+ * ) echo " Unhandled option: -$OPTION " >&2 ; exit 1 ;;
7879 esac
7980done
8081shift $(( OPTIND - 1 ))
8182
8283# Set separate tag for cuRobo image.
83- if [ " $INSTALL_CUROBO " = " true" ]; then
84+ if [[ " $INSTALL_CUROBO " == true ] ]; then
8485 DOCKER_VERSION_TAG=" ${CUROBO_VERSION_TAG} "
8586fi
8687
@@ -89,11 +90,11 @@ CONTAINER_NAME="${DOCKER_IMAGE_NAME}-${DOCKER_VERSION_TAG}"
8990echo " Using Docker image: ${DOCKER_IMAGE_NAME} :${DOCKER_VERSION_TAG} (base: ${BASE_IMAGE} )"
9091
9192# Build the image if it doesn't exist yet, or if a rebuild was requested.
92- if [ " $( docker images -q " ${DOCKER_IMAGE_NAME} :${DOCKER_VERSION_TAG} " 2> /dev/null) " ] && [ " $FORCE_REBUILD " = false ]; then
93+ if [[ -n " $( docker images -q " ${DOCKER_IMAGE_NAME} :${DOCKER_VERSION_TAG} " 2> /dev/null) " && " $FORCE_REBUILD " == false ] ]; then
9394 echo " Image ${DOCKER_IMAGE_NAME} :${DOCKER_VERSION_TAG} already exists. Use -r to force a rebuild."
9495else
9596 BUILD_ARGS=(" --build-arg" " WORKDIR=${WORKDIR} " " --build-arg" " BASE_IMAGE=${BASE_IMAGE} " )
96- if [ " $INSTALL_CUROBO " = " true" ]; then
97+ if [[ " $INSTALL_CUROBO " == true ] ]; then
9798 # Detect the host GPU arch so cuRobo's kernels are compiled for it.
9899 ARCH_LIST=$( detect_cuda_arch) || exit 1
99100 echo " cuRobo enabled — building for TORCH_CUDA_ARCH_LIST=${ARCH_LIST} "
@@ -109,18 +110,18 @@ else
109110fi
110111
111112# Remove a previously-exited container of the same name so we can recreate it.
112- if [ " $( docker ps -a --quiet --filter status=exited --filter " name=^${CONTAINER_NAME} $" ) " ]; then
113+ if [[ -n " $( docker ps -a --quiet --filter status=exited --filter " name=^${CONTAINER_NAME} $" ) " ] ]; then
113114 docker rm " ${CONTAINER_NAME} " > /dev/null
114115fi
115116
116117# Reuse a running container only if it uses the selected image.
117- if [ " $( docker container inspect -f ' {{.State.Running}}' " ${CONTAINER_NAME} " 2> /dev/null) " = " true" ] ; then
118- if [ " $( docker inspect -f ' {{.Image}}' " ${CONTAINER_NAME} " ) " != \
119- " $( docker image inspect -f ' {{.Id}}' " ${DOCKER_IMAGE_NAME} :${DOCKER_VERSION_TAG} " ) " ] ; then
118+ if test " $( docker container inspect -f ' {{.State.Running}}' " ${CONTAINER_NAME} " 2> /dev/null) " = true ; then
119+ if test " $( docker inspect -f ' {{.Image}}' " ${CONTAINER_NAME} " ) " ! = \
120+ " $( docker image inspect -f ' {{.Id}}' " ${DOCKER_IMAGE_NAME} :${DOCKER_VERSION_TAG} " ) " ; then
120121 echo " error: ${CONTAINER_NAME} uses an older image. Stop it and rerun this command." >&2
121122 exit 1
122123 fi
123- if [ " $# " -gt 0 ]; then
124+ if [[ $# -gt 0 ] ]; then
124125 printf -v AUTODATA_COMMAND ' %q ' " $@ "
125126 docker exec --user " $( id -un) " --workdir " ${WORKDIR} " " ${CONTAINER_NAME} " \
126127 bash -ic " ${AUTODATA_COMMAND} "
@@ -132,15 +133,15 @@ if [ "$(docker container inspect -f '{{.State.Running}}' "${CONTAINER_NAME}" 2>/
132133fi
133134
134135add_volume_if_it_exists () {
135- [ -d " $1 " ] && echo " -v $1 :$2 "
136+ [[ -d " $1 " ] ] && echo " -v $1 :$2 "
136137}
137138
138139# Create it as the host user before Docker can create a root-owned bind source.
139140mkdir -p " ${CACHE_HOST_MOUNT_DIRECTORY} "
140141
141142# Forward the host SSH agent if available (so git over SSH works in-container).
142143SSH_DOCKER_ARGS=()
143- if [ -n " ${SSH_AUTH_SOCK:- } " ] && [ -S " $SSH_AUTH_SOCK " ]; then
144+ if [[ -n " ${SSH_AUTH_SOCK:- } " && -S " $SSH_AUTH_SOCK " ] ]; then
144145 SSH_DOCKER_ARGS+=(" -v" " $SSH_AUTH_SOCK :/ssh-agent" " --env" " SSH_AUTH_SOCK=/ssh-agent" )
145146fi
146147
183184# Only allocate a TTY when stdin is a terminal. CI has no TTY, and passing --tty
184185# there fails with "cannot attach stdin to a TTY-enabled container".
185186TTY_ARGS=()
186- if [ -t 0 ]; then
187+ if [[ -t 0 ] ]; then
187188 TTY_ARGS+=(" --tty" )
188189fi
189190
0 commit comments