From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17705 invoked by alias); 29 Apr 2015 06:35: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: 34991 Received: (qmail 28502 invoked from network); 29 Apr 2015 06:35:45 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Message-ID: <55407BBF.6020401@inlv.org> Date: Wed, 29 Apr 2015 08:35:43 +0200 From: Martijn Dekker User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: zsh-workers@zsh.org Subject: [BUG] Can't mark unset variables as read-only Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Unlike other shells, zsh can't mark an unset variable as read-only. Upon encountering the readonly command, the variable is set to the empty string instead. Test code: ( unset -v testv && readonly testv && test "${testv+set}" = '' ) || \ echo "*** Can't keep unset variables as read-only." 1>&2 This succeeds in ash, dash, bash, ksh, etc. but fails in zsh, even in 'emulate sh' mode. Actual result: testv is set to the empty string and marked read-only. Expected result: testv remains unset and is marked read-only. Real-world impact: Testing whether a variable is set is a common way of checking whether a certain setting or feature is active. Hardened scripts may want to set such either-set-or-unset variables as read-only after setting up their environment, to prevent them from being accidentally clobbered. This is not possible in zsh.