Re: Shell - escapes

2016-05-12 Thread Mart van de Wege
Mark Fletcher writes: > On Tue, May 10, 2016 at 9:20 PM wrote: > > If you are embedding longer scripts in your shell, consider using > "here documents", which are more flexible wrt. embedded quotes. > For one-liners, Thomas' solution works nicely. > > > > Except that it doe

Re: Shell - escapes

2016-05-10 Thread David Christensen
On 05/10/2016 06:36 AM, Andy Smith wrote: perl -e 'print q{$ and a} ' +1 David

Re: Shell - escapes

2016-05-10 Thread Thomas Schmitt
Hi, i wrote: > > So this is not a way to express arbitrary literal text. David Wright wrote: > $ wc -c <<"x" Indeed. One more way to reach the goal. At least with bash and dash. Have a nice day :) Thomas

Re: Shell - escapes

2016-05-10 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, May 10, 2016 at 04:19:10PM +0200, Thomas Schmitt wrote: > Regrettably, Here Documents let the shell fiddle with their text. > > $ wc -c < $(echo hello) > x > 6 > > So this is not a way to express arbitrary literal text. Not if you q

Re: Shell - escapes

2016-05-10 Thread David Wright
On Tue 10 May 2016 at 16:19:10 (+0200), Thomas Schmitt wrote: > Regrettably, Here Documents let the shell fiddle with their text. > > $ wc -c < $(echo hello) > x > 6 > > So this is not a way to express arbitrary literal text. $ wc -c <<"x" $(echo hello) x 14 $ Cheers, David.

Re: Shell - escapes

2016-05-10 Thread Thomas Schmitt
Hi, > I think it would be useful to have a (new, meta) quote, which fully hides > contents from bash-interpretion The '' quote does this. It's simply impossible that an end quotation mark can be distinguished from a literal quotation mark. If there would be escaping of literal string end marks, t

Re: Shell - escapes

2016-05-10 Thread David Wright
On Tue 10 May 2016 at 13:16:27 (+), Mark Fletcher wrote: > On Tue, May 10, 2016 at 9:20 PM wrote: > > If you are embedding longer scripts in your shell, consider using > > "here documents", which are more flexible wrt. embedded quotes. > > For one-liners, Thomas' solution works nicely. > > > E

Re: Shell - escapes

2016-05-10 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, May 10, 2016 at 01:36:22PM +, Andy Smith wrote: > Hello, > > On Tue, May 10, 2016 at 11:18:06AM +0200, Die Optimisten wrote: > > How can I escape a ' inside '...' > > e.g. perl -e 'print '$ and a' '# I don't want to use " > > You can'

Re: Shell - escapes

2016-05-10 Thread Andy Smith
Hello, On Tue, May 10, 2016 at 11:18:06AM +0200, Die Optimisten wrote: > How can I escape a ' inside '...' > e.g. perl -e 'print '$ and a' '# I don't want to use " You can't, so if it were me I would use one of perl's alternatives for single-quoted strings, such as: perl -e 'print q{$ and a}

Re: Shell - escapes

2016-05-10 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, May 10, 2016 at 01:14:57PM +, Mark Fletcher wrote: > On Tue, May 10, 2016 at 9:20 PM wrote: > > > > > If you are embedding longer scripts in your shell, consider using > > "here documents", which are more flexible wrt. embedded quotes. >

Re: Shell - escapes

2016-05-10 Thread Mark Fletcher
On Tue, May 10, 2016 at 9:20 PM wrote: > > If you are embedding longer scripts in your shell, consider using > "here documents", which are more flexible wrt. embedded quotes. > For one-liners, Thomas' solution works nicely. > > Except that it does what the OP clearly said he does NOT want to do -

Re: Shell - escapes

2016-05-10 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, May 10, 2016 at 01:54:35PM +0200, Die Optimisten wrote: > > If there was no $ in the text, one could do it more simply by > packing the whole text into double quotes: > perl -e "print '$ and a' " > > Have a nice day :) Thomas > > That's why I

Re: Shell - escapes

2016-05-10 Thread Die Optimisten
> If there was no $ in the text, one could do it more simply by packing the whole text into double quotes: perl -e "print '$ and a' " > Have a nice day :) Thomas That's why I constructed that example :) I think it would be useful to have a (new, meta) quote, which fully hides contents from bas

Re: Shell - escapes

2016-05-10 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, May 10, 2016 at 01:08:04PM +0200, Thomas Schmitt wrote: > Hi, > > to...@tuxteam.de wrote: > >perl -e 'print '"'"'$ and a'"'"' '# I don't want to use " > > You were faster than me. :)) > > > > I.e. just use the '' where you need 'em

Re: Shell - escapes

2016-05-10 Thread Thomas Schmitt
Hi, to...@tuxteam.de wrote: >perl -e 'print '"'"'$ and a'"'"' '# I don't want to use " You were faster than me. :)) > I.e. just use the '' where you need 'em I actually do it vice versa: If purely literal text is intended, i use '' where possible and escape only '. That's most safe be

Re: Shell - escapes

2016-05-10 Thread Thomas Schmitt
Hi, Die Optimisten wrote: > > How can I escape a ' inside '...' > > e.g. perl -e 'print '$ and a' ' Mark Fletcher wrote: > perl -e 'print '\''$ and a'\'' ' Or by ending the range of ' and packing the literal ' into double quotes: perl -e 'print '"'"'$ and a'"'"' ' consisting of these quotati

Re: Shell - escapes

2016-05-10 Thread Frédéric Marchal
On Tuesday 10 May 2016 11:18:06 Die Optimisten wrote: > Hi, > > How can I escape a ' inside '...' > e.g. perl -e 'print '$ and a' '# I don't want to use " This seems to work: perl -e 'print '\''$ and a'\' It must be understood as the concatenation of these strings: * literal string: 'p

Re: Shell - escapes

2016-05-10 Thread shawn wilson
'...' doesn't interpolate. push @f, '$ and a'; push @f, "'"; print join '', @f; If you want. I have a feeling YDIW and need to step back and present the actual problem. On May 10, 2016 05:36, "Die Optimisten" wrote: > Hi, > > How can I escape a ' inside '...' > e.g. perl -e 'print '$ and a' '

Re: Shell - escapes

2016-05-10 Thread Mark Fletcher
On Tue, 10 May 2016 at 18:36, Die Optimisten wrote: > Hi, > > How can I escape a ' inside '...' > e.g. perl -e 'print '$ and a' '# I don't want to use " > > thank you > Andrew > > perl -e 'print '\''$ and a'\'' ' The things that might look like double quotes in the above depending on your fo