On Fri, Mar 16, 2018 at 17:11:09 +0700, Robert Elz wrote: > Date: Thu, 15 Mar 2018 01:20:43 +0000 > From: "Valeriy E. Ushakov" <u...@netbsd.org> > Message-ID: <20180315012043.c3d92f...@cvs.netbsd.org> > > | The manual is still rather inconsistent e.g. when referring to > | parameters where it randomly uses both $0 and 0 or $@ and @ - but I'm > | not shaving that yak at least for now. > > Please be careful if you get cold, and decide you need the wool. > > I have just done a brief scan (of the @ uses at least) and I think > at least most of them are correct as they are (at least, I did not > see any that are not - but I did not look carefully at every one.) > > The man page uses just "@" when it is referring to the name of > the special parameter, and "$@" when it is referring to the results > of expanding that special paramater, so it is correct to say > > $@ expands to ... > but would not be to say > @ expands to > as @ doesn't expand to anything, it is just a character. > > Similarly, > the special parameter @ gives a list of ... > (or "expands to ...") is correct,. but > the special parameter $@ gives ... > would not be, as $@ is not a special parameter (or > not normally.) > > $0 is also the expansion of the special parameter 0, > it would have the same usage rules (though I did not > look for that one - there are far more 0's in the man page > than @'s!)
Yes, I understand that. Though there are still some problematic (at least to my eye) wording in that area. E.g. If there are no positional parameters, the expansion of @ generates zero arguments, even when @ is double-quoted. [...] then "$@" expands to [...] where when @ is double-quoted is, pedantically, wrong. It's not @ that is double-quoted, it's $@. Or: When a shell function is executed, all of the shell positional parameters (except $0, which remains unchanged) are set to [...] where 0 is a special parameter, not a positional parameter, to begin with, and where the principle you refer to in your mail requires "except 0", without the $ sign. Also some of them are in .Dq and some not, so A sub-shell retains the same value of $ as its parent. but the value of the special parameter ``!'' Now, obviously, the exclamation mark without .Dq would be very confusing inside a sentence, but may be it would be a good idea to mark up all of them in this (or some other) way consistently. I also try to add the form with the dollar sign in a comment for the occurences I stumble upon just to make them more searchable in the source at least (cf. "far more zeroes" :). -uwe