Rob Segal
Rob Segal

Reputation: 7625

Quoted parameter passed to shell script from xargs call not receiving correctly

The following xargs call is failing for me and I can't for the life of me figure out why...

param="pvr.ccz:--format cocos2d --disable-rotation --shape-padding 1 --border-padding 0 --opt PVRTC4 --auto-sd --texture-format pvr2ccz --pack-mode Best --size-constraints NPOT"

seq 10 | xargs -I@ -P ${numProcs[${gBuildConfig}]} -n 1 bash -c './generateBackgrounds.sh parallax-stage-@-atlas "*.png" "${param}" Parallax'

All I know is that the way I am quoting the ${param} variable is causing this to not work. My problem is I can't figure out what the quoting should be. Using the existing structure I have above when try to print out the value of ${param} inside of generateBackgrounds.sh I get nothing, just an empty string.

Upvotes: 0

Views: 234

Answers (2)

tripleee
tripleee

Reputation: 189387

The subshell does not have access to params unless you export the variable.

Alternatively, switch from single quotes to double to have $params interpolated by the current shell.

Upvotes: 1

chepner
chepner

Reputation: 531125

Can you call generateBackgrounds.sh directly?

np=${numProcs[${gBuildConfig}]}
seq 10 | xargs -I@ -P $np -n 1 ./generateBackgrounds.sh parallax-stage-@-atlas "*.png" "${param}" Parallax

Upvotes: 1

Related Questions