From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15853 invoked from network); 11 Apr 2021 17:57:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Apr 2021 17:57:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1618163866; b=a4Ei/95hE8Qigp2q0aISI/eu5JovZalvmcGXCCgDdMjfI3Z76ykSq4f204sTfj+RivSqKG3EU/ PDgVzQNCGx5Qosb2SzhY+oj7d00PHzI7Db+nnlcxR9oYmaMlWNV6G9ATidJTJ25/xLGwZ5iOaE bOYPsfALKwyy/b5nzv4G1CLX/GMBq5TcoMwjk2NzSDh38Pb/swo9UXA+I6tARXuLiSeG6AKjzy hkYdZqmuamOqu1r9dBkZQuqNFirz0Fm2QjVWwCQdmAtYdDVU2RCtOoIPlKN/Kdvz2aAUfxpwhM 5sefZEecrTuUluSFqs5yhv/G691GvTiVY0LiNAwY+2rfXw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1618163866; bh=Wz1Xfzny/LV9DeuWs96pwVAKSupxBoL/zCGCKTYrPZM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:DKIM-Signature; b=iHQQg34wfuhUMmktdDKyCfIj55lOpikp0dMIY7fUhEcEmUC0VT8aontNmsE8T1y2n/of5qKTwD 0yO6tv8YYozIrRcPClzHU/uhfCI3OeCrj9FhCvu+quDHauZ/afTnvULOEFNiLau45ozKe27n/r tO19U/DFmw3eM0QIoQhtF42Srgrgu1phAjLeU/wN7fih8pLCvI43yUwS2bVRNcGDhJ9ibbQO6G 1bhAqGRNrJLsCA9Fl6rXZ4UY0AahapbwVKXay9+jWNtUugj1Ve5lGX9LMBHmR1f88eFFOulk5U UibIr6gpyCoXUwZY+ykR/Hn0GOsTS88dZZqdyh8iA0IByA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=SXJ7Dow0QewEpHWvOUMsEtvxIh6zUMEgoRglaZaumck=; b=dNYerp8f/mYDVxDvjhajbTSOkn GIe8gI4pThHdpzDlghiPRtUkv8ST0iu5EX6R6Y6wp1oRl3TMqGJw+THgbFgmigm4kc1zhody14gUu iZXfz+ZBQoN9RvyJi/+efU9qIR62iurv9nE8vTIYaoxgd4ROlo9XCzBNpU47207iFdp7N/mwabBuC Zrc7qi9F8CVPZp5XTmhOvdMBFftRpIDHtIk0LLqxTs3SgWHU1Y3RTllOz71NepCjA5d1bNnY2Q5Ho u34FSNLY/XvUBg7bQKkX5aSA6oVpNKdZ87n1opTKn5Q+/d8ufY1UPx3Z4A8JLpIrgWSHp3w+Pv7Gc mWMAkoGw==; Received: from authenticated user by zero.zsh.org with local id 1lVeLA-000PSh-Dy; Sun, 11 Apr 2021 17:57:44 +0000 Authentication-Results: zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none Received: from relay3-d.mail.gandi.net ([217.70.183.195]:44999) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lVeKu-000PEP-QD; Sun, 11 Apr 2021 17:57:29 +0000 X-Originating-IP: 90.215.204.106 Received: from chazelas.org (unknown [90.215.204.106]) (Authenticated sender: stephane@chazelas.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9FE8860005 for ; Sun, 11 Apr 2021 17:57:27 +0000 (UTC) Date: Sun, 11 Apr 2021 18:57:26 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: sh emulation POSIX non-conformances (Was: [PATCH] Document imperfections in POSIX/sh compatibility) Message-ID: <20210411175726.hxnm33mxoska2tsm@chazelas.org> Mail-Followup-To: Zsh hackers list References: <7FD930F4-37CD-402B-9A06-893818856199@dana.is> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 48498 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Some non-POSIX conformances I can think of ATM: * "echo -" does not output -\n last (or one of the last) time it was brought up, I pointed out that anyway few shells were POSIX compliant in that regard in that for instance POSIX requires "echo -e" to output "-e\n". I've since asked POSIX allow echo -e, echo -E (and combinations of those and -n), and zsh's echo -. They've rejected the latter part. See https://www.austingroupbugs.net/view.php?id=1222 So I think it would make sense now to stop accepting "-" as option delimiter in sh emulation. * a few of zsh's reserved words are still available in POSIX mode. $ zsh --emulate sh -c 'foreach() { true; }' zsh:1: parse error near `()' $ zsh --emulate sh -c 'end() { true; }' zsh:1: parse error near `end' * IFS treated as separator and not delimiter: $ a='a:b:' zsh --emulate sh -c 'IFS=:; printf "<%s>\n" $a' <> (POSIX requires and only). Many shells used to behave like zsh, but switched for POSIX compliance even though the zsh behaviour is more useful for instance to break down variables like $PATH (like /bin:/usr/bin: which should be split into "/bin", "/usr/bin" and ""). * whitespace characters other than SPC/TAB/NL not treated as IFS whitespace. $ a=$'\ra\r\rb' zsh --emulate sh -c $'IFS=\r; printf "<%s>\n" $a' <> <> POSIX requires only and above as isspace('\r') is true so \r should receive the same treatment as space, \t, \n. Few shells do it. bash has only started recently doing it and only for single byte characters (so is not POSIX either). -- Stephane