0

I'm currently working with a large code base, and I want to move some of my bash scripts to run their python commands via a python docker container. To achieve this, I've created a function "python" and placed this in a script which can be sourced into the scripts I want to run via containers

function python() {
    python_command_to_run="${@}"
    docker run --rm --name py-container -v $(pwd):/usr/src/app my_image:latest python ${python_command_to_run}
}

However, python commands I have which contain spaces will not work. An example of said command is the following

python "my_py_script.py" --run_command '"echo hi"'

I believe that when passed into the docker run, the code believes "echo is one command and hi" is another. This is because I'm getting an argument exception in my actual python script

How do I modify the above "python" function or my call of said function such that it treats the "echo hi" as a single command to my python script?

Kieran_M
  • 41
  • 4

0 Answers0