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

2019-05-09 Thread Steffen Nurpmeso
Joerg Schilling wrote in <5cd3de0b.BlFpWvouLTKsxKlh%Joerg.Schilling@foku\ s.fraunhofer.de>: |Steffen Nurpmeso wrote: | |> For compatibilities sake i want to add that the subshell version |> is necessary on Sun OS 5.9, as /usr/xpg4/bin/sh does not support |> set +o "in a format that is

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

2019-05-09 Thread Joerg Schilling
Steffen Nurpmeso wrote: > For compatibilities sake i want to add that the subshell version > is necessary on Sun OS 5.9, as /usr/xpg4/bin/sh does not support > set +o "in a format that is suitable for reinput": I have no 5.9 available anymore, but I can confirm that this works in Solaris 10 or

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

2019-05-08 Thread Steffen Nurpmeso
Robert Elz wrote in <14296.1494903...@andromeda.noi.kre.to>: |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

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

2017-05-17 Thread Steffen Nurpmeso
Stephane Chazelas wrote: |2017-05-17 13:49:18 +0200, Steffen Nurpmeso: |[...] |> vpospar set x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä |> echo "$#: <${1}><${2}><${3}><$4><$5>" |> vput vpospar x quote; eval vpospar set ${x} |> echo $#: <${1}><${2}><${3}><$4><$5>

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

2017-05-17 Thread Stephane Chazelas
2017-05-17 14:41:31 +0100, Geoff Clare: [...] > Regarding the expansion of $1'' I think the standard is clear that > if $1 ends with a non-whitespace IFS character, Jilles is right and > there will be a final empty field. This is because quote removal > is done after field splitting. For example

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

2017-05-17 Thread Geoff Clare
Stephane Chazelas wrote, on 17 May 2017: > > 2017-05-16 23:39:32 +0200, Jilles Tjoelker: > [...] > > This is easily fixed by adding a quoted empty string: > > set -- $1'' > > > > If $1 ends with an IFS character, you get a final empty field. > > If $1 does not end

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

2017-05-17 Thread Stephane Chazelas
2017-05-17 13:49:18 +0200, Steffen Nurpmeso: [...] > vpospar set x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä > echo "$#: <${1}><${2}><${3}><$4><$5>" > vput vpospar x quote; eval vpospar set ${x} > echo $#: <${1}><${2}><${3}><$4><$5> [...] Your problem here is with your usage of echo. You can't use

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

2017-05-17 Thread Robert Elz
Date:Wed, 17 May 2017 10:05:08 +0100 From:Stephane Chazelas Message-ID: <20170517090508.gb6...@chaz.gmail.com> | The initial question was about round-tripping "$@", so an | arbitrary number of arguments. Ah yes, you're right, it was

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

2017-05-17 Thread Steffen Nurpmeso
Robert Elz wrote: |This is the one that in one of the messages I just sent I said |"not previously posted here" ... When there is a leading/trailing ' |it will be slower... | |Aside: to be really correct, without "local" it should really clean up |the vars (in a trap)

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

2017-05-17 Thread Stephane Chazelas
2017-05-17 14:12:28 +0700, Robert Elz: [...] > | Depends. If quoting only a handful a arguments, then that call > | to awk might cost you you a couple of milliseconds indeed. But > | if processing thousands, you might find that it saves a few > | seconds. > > And if I really had an

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

2017-05-17 Thread Robert Elz
Date:Tue, 16 May 2017 17:29:13 +0100 From:Stephane Chazelas Message-ID: <20170516162913.gd3...@chaz.gmail.com> | Sorry about that. I hadn't seen that message at the time I | replied. No, no problem, it was my fault - I should have

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

2017-05-16 Thread Jilles Tjoelker
On Tue, May 16, 2017 at 07:41:43AM +0100, Stephane Chazelas wrote: > 2017-05-16 10:03:56 +0700, Robert Elz: > > Date:Mon, 15 May 2017 18:36:58 +0200 > > From:Steffen Nurpmeso > > Message-ID: <20170515163658.b7ljs%stef...@sdaoden.eu> > [...] > >

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

2017-05-16 Thread Stephane Chazelas
2017-05-16 17:33:26 +0700, Robert Elz: [...] > | Or just write it as quote() (...) instead of quote() { ...;} > > Yes, as you would have seen later, I mentioned that in a subsequent > message. Sorry about that. I hadn't seen that message at the time I replied. [...] > | Here, I'd fire awk

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

2017-05-16 Thread Chet Ramey
On 5/16/17 6:33 AM, Robert Elz wrote: > If we start having shell parsing differently depending on what locale the > user happens to be using, we may as well all give up now, and go find > something else to do. Too late:

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

2017-05-16 Thread Robert Elz
Date:Tue, 16 May 2017 07:41:43 +0100 From:Stephane Chazelas Message-ID: <20170516064143.ga3...@chaz.gmail.com> | Or just write it as quote() (...) instead of quote() { ...;} Yes, as you would have seen later, I mentioned that in a

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

2017-05-16 Thread Steffen Nurpmeso
"Schwarz, Konrad" wrote: |> -Original Message- |> From: Stephane Chazelas [mailto:stephane.chaze...@gmail.com] |> To: Robert Elz |> Cc: Steffen Nurpmeso; austin-group-l@opengroup.org |> Subject: Re: sh(1): is roundtripping of the positional parameter stack

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

2017-05-16 Thread Schwarz, Konrad
> -Original Message- > From: Stephane Chazelas [mailto:stephane.chaze...@gmail.com] > To: Robert Elz > Cc: Steffen Nurpmeso; austin-group-l@opengroup.org > Subject: Re: sh(1): is roundtripping of the positional parameter stack > Here, I'd fire awk and quote more than one arg at a time: >

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

2017-05-16 Thread Stephane Chazelas
2017-05-16 10:03:56 +0700, Robert Elz: [...] > $ y=$(quote "$x") [...] > Just remember to always quote variable references "$x" unless you are > 100% certain what the content of the variable is, eg: as above with $y > where we know it is the result of the quote function, so is safe. [...] No,

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

2017-05-16 Thread Stephane Chazelas
2017-05-16 10:03:56 +0700, Robert Elz: > Date:Mon, 15 May 2017 18:36:58 +0200 > From:Steffen Nurpmeso > Message-ID: <20170515163658.b7ljs%stef...@sdaoden.eu> [...] > Alternatively, you could implement this as an external #! script, that > would be

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

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: 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 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