Diolor
Diolor

Reputation: 13450

Bash extract double quotes command to param

Very entry level question.

For the given working script:

#!/bin/bash
./configure $FLAGS --extra-cflags="-I$TOOLCHAIN_PREFIX/include $CFLAGS"

Is it possible to extract the "-I$TOOLCHAIN_PREFIX/include $CFLAGS" part into a parameter?

E.g. Amongst others, I tried the following which will fail with unexpected EOF while looking for matching `"' :

#!/bin/bash
EXTRACT="\"-I$TOOLCHAIN_PREFIX/include $CFLAGS\""
./configure $FLAGS --extra-cflags=$EXTRACT

Upvotes: 2

Views: 41

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

EXTRACT="-I$TOOLCHAIN_PREFIX/include $CFLAGS"
./configure $FLAGS --extra-cflags="$EXTRACT"

Word Splitting on Greg's Wiki

Upvotes: 1

Related Questions