I would like to add multiple -e command dynamically to perl but it throws multiple errors like this:
String found where operator expected at -e line 2, near "'s/\$testName/\$test-name/g;'" (Missing semicolon on previous line?)
Heres what I'm doing:
find css -name "*.scss" -print0 | \
xargs -0 -t perl -pi \
$(perl -ne '/^(\$(?=[a-z0-9]*[A-Z])[^:\s]+)\s*:/ && print "-e \047s/\\$1/\\" . lc(join("-", split(/(?=[A-Z])/, $1))) . "/g;\047\n"' _variables.scss | sort -ur | tr "\n" " ")
The command $(perl -ne ...) extracts and transforms some content and outputs something like:
-e 's/\$testName/\$test-name/g;' -e 's/\$coolName/\$cool-name/g;' -e 's/\$camelCased/\$camel-cased/g;'
As far as I can tell the problem resides in the way bash/perl evaluates the last command, the manual execution of the command output by "xargs -t" works fine.
The following simple case fails too:
target="-e 's/\$testName/\$test-name/g;' -e 's/\$coolName/\$cool-name/g;' 's/\$camelCased/\$camel-cased/g;'"
perl -pi $target css/core.scss
xargs, to the outer perl or the inner one?