bash type exit if something go wrong substitute shell variables in complex text files