Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15560 > unrolled thread

Re: Feature Request: Custom delimeter for single quotes

Started byL A Walsh <bash@tlinx.org>
First post2019-11-02 23:08 -0700
Last post2019-11-02 23:08 -0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Feature Request: Custom delimeter for single quotes L A Walsh <bash@tlinx.org> - 2019-11-02 23:08 -0700

#15560 — Re: Feature Request: Custom delimeter for single quotes

FromL A Walsh <bash@tlinx.org>
Date2019-11-02 23:08 -0700
SubjectRe: Feature Request: Custom delimeter for single quotes
Message-ID<mailman.487.1572761402.13325.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web