#!/bin/bash
shopt -s nullglob
eval="c:cd(\\\"src/\\\"),"
for f in src/*.erl
do
filename=`basename "$f"`
eval=${eval}" c:c(\\\"$filename\\\"),"
done
eval=${eval}" c:q()."
echo erl -eval "\""${eval}"\""
erl -eval "\""${eval}"\""
Here, if i copy echo output and run it from command line – its working, but last line failed( I have tested different approaches with quotes and escape chars, but unsuccessfully.
You don’t need the backslashes to be part of the string you’re building (it’s all quoted anyway), and you don’t need the extra double quotes when calling
erl -eval: