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

Re: triviality regarding $# counts



On Sat, Apr 13, 2024 at 1:36 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2024-04-13 12:45, Bart Schaefer wrote:
> > redline () { echo -e "$red$*$nrm" }
> >
> So, compared to the previous expansion, how would '$*' expand there?

redline a b c

would mean

echo -e "$red$1 $2 $3$nrm"

One word, with two quoted spaces, instead of three words.

> I'm unclear as to the practical  difference.

For "echo" it doesn't matter because echo is also going to paste its
arguments together, but it might matter to some other command.

> Anyway .... when my typedef -p line showed those "   ' '    " with no
> dollar -- which seemed to me to forbid that "   $'...'  " grammar --
> what I should read is that that element has nothing quoted ergo no
> 'controller' -- no expansion flag -- is needed.  Yes?  IOW the dollar
> might have been put there, but it has no work to do so is simply
> omitted.  Logical.  Do I have that right, for once?

You do, though I would caution not to think of the $ as an "expansion
flag" -- it's just part of the quoting syntax.




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