passing values to a flag in bash script

5/28/2019

I am preparing shell(.sh) scripts to use my kubernetes and pks command line in kubernetes command we have flags like --image and i am not able to pass the arguments in it

i have tried the convential way of passing the arguments like image=$1

echo $image

the echo statement prints the value well and good $ name is also passing in the command but the script give the error image needed i.e image is not given in the command.

image=$1
hostPort=$2
name=$3
echo $image
kubectl --insecure-skip-tls-verify run $name --image= $image --port= $hostPort

the echo statement prints the value well and good $ name is also passing in the command but the script give the error image needed i.e image is not given in the command.

-- deepankur singh
bash
kubernetes
shell

1 Answer

5/28/2019

Options such as --image must typically be separated by either space or an equals sign from their value. So --image="$image" and --image "$image" will probably both work. "Typically" and "probably" because there's nothing stopping someone from writing some really crazy argument handling to actually support the way it's run here, but I've never seen that before.

-- l0b0
Source: StackOverflow