I am trying to execute a command like this
./build -t -c cflag="-Os -march=haswell"
The following is my script:
#!/bin/bash
set -x
ARGS=" -t"
MARCH=${MARCH:-haswell}
CFLAG="-Os"
CFLAG+=" -march=$MARCH"
ARGS+=" -c cflag=\"${CFLAG}\""
./build $ARGS
Here is build
:
#!/usr/bin/env python3
import sys
for arg in sys.argv:
print(arg)
Bash always adding extra single quotes in the command:
+ ARGS=' -t'
+ MARCH=haswell
+ CFLAG=-Os
+ CFLAG+=' -march=haswell'
+ ARGS+=' -c cflag="-Os -march=haswell"'
+ ./build -t -c 'cflag="-Os' '-march=haswell"'
./build
-t
-c
cflag="-Os
-march=haswell"
Is there a way to disable this behavior in bash?