How Do I Code Switches with the Dash in Bash Shell Scripts?
So I'm Writing a Bash Shell Script for Launching Dockers to Control Whether They Are Interactive or Persistent After Instantiating, and Give Them a Name. in...
So I'm writing a bash shell script for launching dockers to control whether they are interactive or persistent after instantiating, and give them a name. In the command line I will include the switches to do this, like foo.sh --rm -it project1 and my bash script is:
#!/bin/bash
#Accepts specific switch values
#remove docker upon exit -> use --rm in first position
remove=$1
#open up docker in interactive shell --> use -it in second position
interactive=$2
#pass a name for the project --> pass the name in the third position. No name = projectA
named=$3
workdir="/home/s589/Desktop/WORMHOLE"
datadir="/home/s589/Desktop/celeba"
if ["$named" = ""]; then
named="projectA"
fi
docker run --gpus all -it -p 8888:8888 --ipc=host --shm-size 24G "$remove" "$interactive" --name="$named" \
-v $workdir:/workspace \
-v $datadir:/workspace/celeba \
fastai:1.0.34
Of course if I pass the wrong thing it doesn't work, so I would have to write error correction. Isn't there a more elegant way to do this?