On 2019/10/31 21:54, Patrick Blesi wrote:
> I'm looking for a hybrid between single quotes and a here doc or here
> string.
>
> The main use case is for accepting arbitrary user-specified text. I would
> like to wrap this text in single quotes so as to prevent any variable
> expansion or interpretation of the text of any kind. Additionally, I would
> like to allow the users to include single quotes in their text without
> requiring that they escape these quotes.
>   

I can't say for certain, but is there any reason why this wouldn't
work?  As long as the user input doesn't match the generated uuid,
it should be hard to match it as a delimiter...

I am probably missing something obvious, but this would seem to
solve your problem, no?



read usercmd       # or whatever/however you get the command

delim=$(uuidgen)
printf -v cmd "sh -c <<'%s'\n%s\n%s\n" "$delim" "$usercmd" "$delim"
eval $cmd


Reply via email to