From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 8b54c030 for ; Fri, 3 Jan 2020 14:01:16 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id CE99F9518A; Sat, 4 Jan 2020 00:01:15 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 5980D9516B; Sat, 4 Jan 2020 00:01:00 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 985D89516B; Sat, 4 Jan 2020 00:00:59 +1000 (AEST) Received: from sdaoden.eu (sdaoden.eu [217.144.132.164]) by minnie.tuhs.org (Postfix) with ESMTPS id 2092595165 for ; Sat, 4 Jan 2020 00:00:59 +1000 (AEST) Received: by sdaoden.eu (Postfix, from userid 1000) id B6D2916054; Fri, 3 Jan 2020 15:00:57 +0100 (CET) Date: Fri, 03 Jan 2020 15:00:55 +0100 From: Steffen Nurpmeso To: markus schnalke Message-ID: <20200103140055.XB8iT%steffen@sdaoden.eu> In-Reply-To: <1inMKv-0Km-00@marmaro.de> References: <1inMKv-0Km-00@marmaro.de> Mail-Followup-To: markus schnalke , tuhs@tuhs.org User-Agent: s-nail v14.9.16-56-ged842572 OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [TUHS] sh: cmd | >file X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tuhs@tuhs.org Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" markus schnalke wrote in <1inMKv-0Km-00@marmaro.de>: |Hoi, Morsche. |in a computer forum I came across a very long command line, |including `xargs' and `sh -c'. Anyways, throughout the thread |it was modified several times, when accidently a pipe symbol |appeared between the command and the output redirection. The |command line did nothing; it ran successful. I was confused, |because I expected to see a syntax error in case of |``cmd|>file''. This made me wonder ... | | |With help of Sven Mascheck, I was able to clear my understanding. |The POSIX shell grammer provided the answer: ... |A redirection is a (full) simple_command ... and because |``simple_command | simple_command'' is allowed, so is |``io_file | io_file''. This can lead to such strange (but |valid) command lines like: |=20 | b=20 |>b | :=20 | |Here some further fun variants: |=20 |:|:>:=20 | | <:|:>:=20 | |They would provide nice puzzles. ;-) ... |- Syntax ok in these shells: | |SVR2 sh (Ultrix), SVR4 sh (Heirloom) Be aware of spurious :> errors in Heirloom shell, and maybe its origin (never had those). It is why the unit test of my little web site builder thing has been switched to "printf '' > FILE". |ksh93 |bash-1.05, bash-aktuell |pdksh-5.2.14 |ash-0.4.26, dash-0.5.6.1 |posh-0.3.7, posh-0.12.3 |mksh-R24, mksh-R52b |yash-2.29 |zsh-3.0.8, zsh-4.3.17 | |- Exception to the rule: | |7thEd sh: | |=C2=A0=C2=A0=C2=A0 # pwd|>>file |=C2=A0=C2=A0=C2=A0 # echo $? |=C2=A0=C2=A0=C2=A0 141 | |On first sight ok, but with a silent error ... SIGPIPE (128+13). | |I'd be interested in any stories and information around this |topic. | |What about 7thEd sh? Beware of bugs in the above code; I have only proved it correct, not tried it. |meillo --End of <1inMKv-0Km-00@marmaro.de> --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)