Way to pass a script as a docker build argument?

I want to pass a multi-line script as a argument to docker build command, something like that:

docker build -t tertparam --build-arg load_cat_agent=true --build-arg deploy_cat_script='
echo "aaa";
echo "bbb"
' --no-cache .

and execute it during build, my Dockerfile is like

FROM python:3-alpine

ARG load_cat_agent
ARG deploy_cat_script

ADD . /root/
WORKDIR /root/

RUN if [ $load_cat_agent == "true" ]; then 
         $deploy_cat_script;
    fi
    CMD /root/start.sh && /root/wait.sh

but i found that it always just print

Step 6/7 : RUN if [ $load_cat_agent == "true" ]; then    $deploy_cat_script;    fi
 ---> Running in 7868c310e8e5

"aaa" echo "bbb"

how can i do that?

Source: StackOverflow