NetBSD Problem Report #47795

From www@NetBSD.org  Sat May  4 13:01:36 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id F381F63E6F7
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  4 May 2013 13:01:35 +0000 (UTC)
Message-Id: <20130504130135.48D3D63E6F7@www.NetBSD.org>
Date: Sat,  4 May 2013 13:01:35 +0000 (UTC)
From: sdaoden@gmail.com
Reply-To: sdaoden@gmail.com
To: gnats-bugs@NetBSD.org
Subject: ksh(1): unset(1)ting a readonly variable stops evaluation of startup script
X-Send-Pr-Version: www-1.0

>Number:         47795
>Category:       bin
>Synopsis:       ksh(1): unset(1)ting a readonly variable stops evaluation of startup script
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 04 13:05:00 +0000 2013
>Last-Modified:  Mon May 06 18:20:03 +0000 2013
>Originator:     Steffen
>Release:        NetBSD 6.99.19 (GENERIC) #0: Sun Apr 28 17:23:09 UTC 2013
>Organization:
>Environment:
>Description:
>>>
      # Determine shell type; aux while there
      echo BEFORE
      unset KSH_VERSION
      echo AFTER
      case ${0} in
===
NetBSD 6.99.19 (GENERIC) #0: Sun Apr 28 17:23:09 UTC 2013

Welcome to NetBSD!
[.]
Thank you for helping us test and improve NetBSD.

BEFORE
ksh: /home/steffen/.shrc[125]: unset: KSH_VERSION is read only
<<<

This is an interactive shell, and POSIX says
(XCU, chapter 2: Shell Command Language):

  2.8.1 Consequences of Shell Errors
  For a non-interactive shell, an error condition encountered by
  a special built-in (see Special Built-In Utilities) or other type
  of utility shall cause the shell to write a diagnostic message to
  standard error and exit as shown in the following table:
  […]
  In all of the cases shown in the table, an interactive shell
  shall write a diagnostic message to standard error without
  exiting.

The shell doesn't exit, but it stops evaluation of the startup
file(s) instead of simply printing the error and setting $? to 1.
I think this behaviour is wrong.
>How-To-Repeat:

>Fix:

>Audit-Trail:
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: re: bin/47795: ksh(1): unset(1)ting a readonly variable stops evaluation of startup script
Date: Mon, 06 May 2013 23:45:19 +1000

 i think it is user-friendly for this not to fail with exit,
 regardless of what POSIX says.

 if i break my .shrc, suddenly i can't login to fix it.


 .mrg.

From: Steffen "Daode" Nurpmeso <sdaoden@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/47795: ksh(1): unset(1)ting a readonly variable stops
 evaluation of startup script
Date: Mon, 06 May 2013 20:12:33 +0200

 Hello,

 matthew green <mrg@eterna.com.au> wrote:
  |The following reply was made to PR bin/47795; it has been noted by GNATS.
  |
  |From: matthew green <mrg@eterna.com.au>
  |To: gnats-bugs@NetBSD.org
  |Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
  |Subject: re: bin/47795: ksh(1): unset(1)ting a readonly variable stops \
  |evaluation of startup script
  |Date: Mon, 06 May 2013 23:45:19 +1000
  |
  | i think it is user-friendly for this not to fail with exit,
  | regardless of what POSIX says.
  |=20
  | if i break my .shrc, suddenly i can't login to fix it.

 =E2=80=A6 luckily you can :)
 But it's nonetheless a real bug (or, say -- ignorance of POSIX):

   $ ksh -i -c 'echo BEFORE; unset KSH_VERSION; echo AFTER'

  | .mrg.

 Ciao,

 --steffen

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.