[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell - escapes



-----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 constructed that example :)
> 
> I think it would be useful to have a (new, meta) quote, which fully
> hides contents from bash-interpretion
> so that (perl-)strings can be built without thinking of quoting/escaping.
> Would it be useful / possible to change '...' so that nothing
> _except_ \'  ist interpreted, I think that would be a nice solution
> --- or use a new (unused???) character.
> - Is it worth to forward it to the bash-experts (perhaps sb of them
> reading this...)

You can try that, but be warned that shell (Unix) syntax in general and
bash syntax in particular is a rather mature affair, result of many
shaping forces (esp. compatibility to other shells and backward compatibility
considerations). At this point in history it has achieved an exquisite
equilibrium and there's a huge body of scripts to cater for.

So motivation to change syntax at such a basic level is probably
pretty low (and with a reason).

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.

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlcx0gwACgkQBcgs9XrR2kb6TACfYgdtxEWKUq63xrKc8E53Gd/b
QHoAn0/3IB0YTKnmSKVV6LDx6sFwR97A
=KOjh
-----END PGP SIGNATURE-----


Reply to: