Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Robert Elz via austin-group-l at The Open Group
Date:Wed, 8 Sep 2021 09:09:35 +0100 From:"Geoff Clare via austin-group-l at The Open Group" Message-ID: <20210908080935.GA26035@localhost> | yash's creator(s) are right that a newline cannot occur within a line. | The definition of "line" in XBD chapter 3 is "A

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Robert Elz via austin-group-l at The Open Group
Date:Wed, 8 Sep 2021 11:51:27 +0100 From:Harald van Dijk Message-ID: <84fcabec-16f2-3bd2-0871-cefe53455...@gigawatt.nl> | Only speaking for gwsh, but yes, I consider this is a bug and will make | sure to fix it. Yes, it is a bug. I just fixed it for the NetBSD

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Oğuz via austin-group-l at The Open Group
8 Eylül 2021 Çarşamba tarihinde Harald van Dijk yazdı: > On 08/09/2021 08:15, Oğuz via austin-group-l at The Open Group wrote: > >> Sorry for butting in, but according to the standard, is there really a >> syntax error in the following? >> >> sh -c ': << do | for x in xxx >> do >> do echo $x >>

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Harald van Dijk via austin-group-l at The Open Group
On 08/09/2021 08:15, Oğuz via austin-group-l at The Open Group wrote: Sorry for butting in, but according to the standard, is there really a syntax error in the following? sh -c ': << do | for x in xxx do do echo $x done' busybox sh, dash, gwsh, netbsd sh, and freebsd sh complain about a

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Joerg Schilling via austin-group-l at The Open Group
"O?uz via austin-group-l at The Open Group" wrote: > Sorry for butting in, but according to the standard, is there really a > syntax error in the following? > > sh -c ': << do | for x in xxx > do > do echo $x > done' > > busybox sh, dash, gwsh, netbsd sh, and freebsd sh complain about a >

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Geoff Clare via austin-group-l at The Open Group
Robert Elz wrote, on 08 Sep 2021: > > That's where the null string end delimiter I mentioned last time came > from, "" is a shell word (even after quote removal). But it turns out > that wasn't the example I really wanted to use (that's too easy a case > to get right). The one I wanted was

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-08 Thread Oğuz via austin-group-l at The Open Group
Sorry for butting in, but according to the standard, is there really a syntax error in the following? sh -c ': << do | for x in xxx do do echo $x done' busybox sh, dash, gwsh, netbsd sh, and freebsd sh complain about a missing `done'.

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-07 Thread Robert Elz via austin-group-l at The Open Group
Date:Tue, 7 Sep 2021 16:28:15 +0100 From:"Geoff Clare via austin-group-l at The Open Group" Message-ID: <20210907152815.GA21704@localhost> | Clearly my mental model of how the shell would search for the delimiter | (either before or after it removes ) is too

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-07 Thread Geoff Clare via austin-group-l at The Open Group
Robert Elz wrote, on 07 Sep 2021: > > | But, as I mentioned above, if the shell looks for the delimiter before > | it removes instead of after, it will get this > | case wrong: > | > | $ cat < | > foo\ > | > EOF > | > EOF > | fooEOF > | $ > > Sure: From the NetBSD sh

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-07 Thread Robert Elz via austin-group-l at The Open Group
Date:Tue, 7 Sep 2021 10:29:18 +0100 From:"Geoff Clare via austin-group-l at The Open Group" Message-ID: <20210907092918.GA29665@localhost> | But, as I mentioned above, if the shell looks for the delimiter before | it removes instead of after, it will get this

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-07 Thread Geoff Clare via austin-group-l at The Open Group
Robert Elz wrote, on 06 Sep 2021: > > | Which ones do it the other way? All the shells I tried (bash, dash, > ksh88, > | ksh93, mksh) do it "right". > > FreeBSD (or at least the slightly old version I have to test) and NetBSD: > > sh $ a=foo; b=bar; a=$b b=$a; echo $a$b > barfoo > sh $

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-06 Thread Robert Elz via austin-group-l at The Open Group
Date:Tue, 7 Sep 2021 01:09:00 +1000 From:"G. Branden Robinson via austin-group-l at The Open Group" Message-ID: <20210906150859.2pjbhdtwmqoqgzoq@localhost.localdomain> | > (Sorry, I haven't turned off PS2 in my yash shell setup). All 3 ash | > derived shells

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-03 Thread Harald van Dijk via austin-group-l at The Open Group
On 03/09/2021 13:23, Robert Elz via austin-group-l at The Open Group wrote: and ksh93 did: ksh93 $ cat < It looks like ksh93 fails to properly handle backslash-newline pairs that occur during determination of whether the current line is the heredoc delimiter, so any backslash-newline after a

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-03 Thread Robert Elz via austin-group-l at The Open Group
Date:Fri, 3 Sep 2021 11:05:24 +0100 From:"Geoff Clare via austin-group-l at The Open Group" Message-ID: <20210903100524.GA17338@localhost> | If cmd is not a special built-in or a function, it is already | explicitly unspecified. Yes, I was actually more

Re: shell: swapping var values in one command, plus some here doc stuff

2021-09-03 Thread Geoff Clare via austin-group-l at The Open Group
Robert Elz wrote, on 03 Sep 2021: > > if one wants to do > > a=$b b=$a cmd > > is there any way to make that do what is expected (or perhaps hoped), > that can be relied upon to work? > > That is is one of the following actually specified to work? > > a=$b b=$a > ort=$a a=$b

shell: swapping var values in one command, plus some here doc stuff

2021-09-02 Thread Robert Elz via austin-group-l at The Open Group
First, just to avoid anyone wasting time by pointing it out, to exchange the values of two variables in sh, the following works, and is the safe way to do it t=$a ; a=$b ; b=$t (then unset t if you want). But using multiple commands isn't always possible, eg: without resorting to