From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23893 invoked by alias); 16 Dec 2013 19:11:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32134 Received: (qmail 8112 invoked from network); 16 Dec 2013 19:11:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=M3f2yfa7+Xa9vVVOGswCRbUQXF8YXXQGynv1fWRjfZ8=; b=Hhggagm/5j1SzxL3eotDbvutS/7m40zliMgSufv2KeLdKa1LqHABfT8872I277834g hfUg8S5Jw/pjvZiteJ6CgHPHjrOfwp4fcsZYGBCHdUVysv7F7QgAt7L57CAOMd11QV9G g9hI5FxkHtf+okrJ/YQOe//VZA79uro+kFiMmrK+5cpUs6Qq6VOuuSz5JZGKscL2qS/G HxCr3budUaJzLhfrU9FDsPiQVBTP33k70CK1qbfzhVU3YcRgej7WdFtuch33FLoswnJC GarPVdDzhcajBba2SnWG8dKI6q6FQvazsZaL0gnwabhxMDDriQPRf8V0AA2n7q4pAOfX vlEQ== X-Received: by 10.53.2.36 with SMTP id bl4mr3863078vdd.32.1387221089225; Mon, 16 Dec 2013 11:11:29 -0800 (PST) MIME-Version: 1.0 From: =?UTF-8?Q?=C3=98ystein_Walle?= Date: Mon, 16 Dec 2013 20:10:49 +0100 Message-ID: Subject: Read-only variables in emulation mode To: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Consider the following: emulate sh -c ' some_name() { status=3Dworld echo "hello $status" } some_name ' Running it gives: some_name:1: read-only variable: status This is a problem if you source a "library" meant to be used by different versions of different shells: $ cat =3Dgit-example #!/bin/zsh emulate sh -c ' . git-sh-setup ' ... require_work_tree ... $ git example die_with_status:1: read-only variable: status A common idiom in (ba)sh scripting is to use _ as a throwaway in a while-read loop: while read -r col1 _ col2; do echo "col1 =3D $col1 and col2 =3D $col2" done < three-columns.txt This also fails with an equivalent message when used in sh emulation. Is it fixable? (Is the general opinion that it needs fixing?). I assume status and _ are meant to be writable in POSIX shells. I suppose an idea would be for various variables to be writable within emulate -c '...' and later in the functions defined therein. How this would affect the rest of the shell is hard to say for me. In the mean time, is there any way around it? Thanks =C3=98sse