Re: Shell parameter expansions involving '#"

2017-05-15 Thread Geoff Clare
Robert Elz wrote, on 14 May 2017: > > For NetBSD, I've just created a shell test of expansions where there > is a '#' involved.. > > The test includes the following comments... > > # > # $# looks like it should be so simple that it doesn't really > # need a test of

Re: Shell parameter expansions involving '#"

2017-05-15 Thread Robert Elz
Date:Mon, 15 May 2017 10:03:04 +0100 From:Geoff Clare Message-ID: <20170515090304.GA12956@lt2.masqnet> Thanks for the reply. | Explicitly unspecified in XCU 2.6.2. Oh, sorry, I should have been clearer, I know that. I will however add extra

Re: Shell parameter expansions involving '#"

2017-05-15 Thread Geoff Clare
Robert Elz wrote, on 15 May 2017: > > | ${#-} and ${#?} are the lengths of $- and $? (not treated as ${var-word} > | or ${var?word} with an empty word). > > Thanks, I should add tests for those as well, (and ${#$} etc too, though they > have no other possible meaning).

Re: Shell parameter expansions involving '#"

2017-05-15 Thread SHwareSyst
I'm wondering, is it desirable to have a precedence of checking list, since '#' can be either parameter name or operator in that context, or require if there is ambiguity that the # special parameter be represented as $# inside the braces? I'm thinking 'foo=$# ${#foo##pat}' and '${pat}'

sh(1): is roundtripping of the positional parameter stack possible? (Was: Re: Shell parameter expansions involving '#")

2017-05-15 Thread Steffen Nurpmeso
Hello. I am wondering whether this is possible in (POSIX) sh(1)ells, as an alternative to arrays, so to say, as i just cannot find a way to achieve it, i always loose the quotes and finally end up where i do not want to end. Something like this (in the MUA i maintain, which does not support

RE: sh(1): is roundtripping of the positional parameter stack possible? (Was: Re: Shell parameter expansions involving '#")

2017-05-15 Thread Shware Systems
It is not built in as a standard feature, ($@ has limitations) but it is plausible to write shell functions that convert the list to CSV format values, and back, as a "shell only" solution. On Monday, May 15, 2017 Steffen Nurpmeso wrote: Hello. I am wondering whether this

Re: sh(1): is roundtripping of the positional parameter stack possible? (Was: Re: Shell parameter expansions involving '#")

2017-05-15 Thread Robert Elz
Date:Mon, 15 May 2017 18:36:58 +0200 From:Steffen Nurpmeso Message-ID: <20170515163658.b7ljs%stef...@sdaoden.eu> | Is it at all possible to store the parameter stack in a variable | "x" in order to restore it exactly "as-is", in the shell?

Re: sh(1): is roundtripping of the positional parameter stack possible? (Was: Re: Shell parameter expansions involving '#")

2017-05-15 Thread Robert Elz
Date:Tue, 16 May 2017 10:03:56 +0700 From:Robert Elz Message-ID: <14296.1494903...@andromeda.noi.kre.to> | Just remember to always quote variable references "$x" And then I see I forgot in ... $ stack="$(quote $x):$*" which is one of the

Re: Shell parameter expansions involving '#"

2017-05-15 Thread Robert Elz
Date:Mon, 15 May 2017 17:39:41 -0400 From:shwares...@aol.com Message-ID: <9ac89.7ef84acb.464b7...@aol.com> | I'm thinking 'foo=$# ${#foo##pat}' There is only ever one modification operator allowed in a (standard) variable expansion, that can be the prefix '#'

Re: sh(1): is roundtripping of the positional parameter stack possible? (Was: Re: Shell parameter expansions involving '#")

2017-05-15 Thread Robert Elz
Date:Tue, 16 May 2017 10:03:56 +0700 From:Robert Elz Message-ID: <14296.1494903...@andromeda.noi.kre.to> I keep replying to my own mail. This is really not a good sign! | Alternatively, you could implement this as an external #! script, that