Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: triviality regarding $# counts





On 2024-04-14 10:42, Mark J. Reed wrote:
...  That means all of these assignments store exactly the same thing in the variable x:

x=this\ is\ all\ one\ word
That one is new to me.  So a quoted or escaped space is no longer a word delimiter.  Yeah ... that's why in typeset, any naked space is a delimiter, even a dozen of them make no difference, they are 'just' delimiters.  Yup, this kind of thing won't catch me again.

x="this is all one word"
x='this is all one word'
x=$'this is all one word'
x=this\ is' 'all" "one$' 'word

The ability to mix and match gives us the old way to get an apostrophe into an otherwise-single-quoted string: to close the quotes, add a backslashed apostrophe, and then go back into quotes:

x='That'\''s all, folks!'

Geez ... that's dicing with the law. I'm seeing:
'That'
then an escaped apostrophe, so literal,  then
's all, folks!"
... three ... dunno how to say it ... three words joined into one.

But it's easier to just use ANSI quotes:

x=$'That\'s all, folks!'
 
Yes, that's clear.

--
Mark J. Reed <markjreed@xxxxxxxxx>



Messages sorted by: Reverse Date, Date, Thread, Author