TobiX <tobix@supereva.it> wrote:
> I have a variable which contains some random string. I need to include
> that string into an eval, or into the -c parameter of a bash invocation.
> (Why I have to do so is beyond the scope of this discussion.)
>
> In order to do so, I need to put the string inside single quotes and
> substitute every single quote in the string with '\'' .
> This is simpler than using double quotes and backslashing dollars, etc.
Regardless of the nature and existence of any bug here, your case is
easily handled by exporting the variable and then fetching it from the
environment.
paul