OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Behaviour of ksh(1)

From: Steffen (sdaodengmail.com)
Date: Thu May 02 2013 - 09:18:20 CDT


Ted Unangst <tedutedunangst.com> wrote:
 |On Thu, May 02, 2013 at 13:12, Steffen "Daode" Nurpmeso wrote:
 |> Hi, you should try
 |>
 |> echo BEFORE
 |> unset KSH_VERSION
 |> echo AFTER
 |
 |ksh: unset: KSH_VERSION is read only
 |
 |So don't unset it?

Yep it's nasty hah. Still, you get

  BEFORE
  ksh: unset: KSH_VERSION is read only

and .profile is read by an interactive shell, so evaluation must
not stop here, as has been revealed on the mksh(1) list -- 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.
Buggy imho.

P.S.: thanks for CCing me, i've forgot that..

--steffen