Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zsh in ksh emulation mode: typeset -i "allows" string as variable value



We're running zsh in ksh emulation. It has come to our attention that
it's possible to assign a non-integer value to a variable defined as
integer with "typeset -i" (or with "integer"). 

After assigning a string to an integer variable, the exit code is 0. The
new value of the variable is 0 aswell. 

On HP-UX's ksh, however, such an operation isn't permitted resulting in
an error message and an exit code of 1.

Is this normal behaviour for zsh or a bug? Can this behaviour be changed
through zsh' options?


For example, zsh-4.2.6-2.hotfix on RHEL 5.1 x86_64

foo@bar: typeset -i day=5
foo@bar: echo $?
0
foo@bar: echo $day
5
foo@bar: day=five
foo@bar: echo $?
0
foo@bar: echo $day
0
foo@bar: typeset -i day=five
foo@bar: echo $?
0
foo@bar: echo $day
0
foo@bar: uname -a
Linux bar 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64
x86_64 x86_64 GNU/Linux
foo@bar: rpm -q zsh
zsh-4.2.6-2.hotfix

... and ksh on HP-UX 11.11

foo@hpux: typeset -i day=5
foo@hpux: echo $?
0
foo@hpux: echo $day
5
foo@hpux: day=five
ksh: five: bad number
foo@hpux: echo $?
1
foo@hpux: echo $day
5
foo@hpux: uname -a
HP-UX hpux B.11.11 U 9000/800 645092970 unlimited-user license


---

Tristan Terpelle
____

This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful.

Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy.

Any views expressed in this message are those of the sender.




Messages sorted by: Reverse Date, Date, Thread, Author