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

zsh-2.6-beta18: an incompatibility with ksh in typeset command



     This is a report on the problem which I had noticed in
zsh-2.6-beta16 and had sent you a bug-report on the 9th May.
But it seems that no improvement had done for now.  Maybe my
report had lost somewhere no one knows...  So, I decided to
report it again.  (Excuse me if this is a redundant report.)

     The problem I found is a slight incompatibility between the
Z Shell and the Korn Shell (ksh, hereafter).

     In ksh, the optional numeric argument of `typeset' command,
which is typically used to specify the output arithmetic base,
is placed just after the option(s) of the command:

	$ typeset -i2 a
	$ a=10
	$ echo $a
	2#1010
	$ 

In zsh-2.6-beta18, however, you must put a space between the
option and numeric argument, like this:

	% typeset -i 2 a

This is an annoying difference.

The following is a sample fix; it preserves the backward
compatibility by extending only the erroneous case, though it is
quick-and-dirty...

*** builtin.c.orig	Tue May 21 18:00:23 1996
--- builtin.c	Fri May 24 06:24:16 1996
***************
*** 125,133 ****
  		    break;
  	    /* the above loop may have exited on an invalid option */
  	    if (*arg) {
! 		zerr("bad option: %c", NULL, *arg);
! 		zsfree(xarg);
! 		return 1;
  	    }
  	    /* handle the special "set" options */
  	    arg = (char *) ugetnode(args);
--- 125,142 ----
  		    break;
  	    /* the above loop may have exited on an invalid option */
  	    if (*arg) {
! 		/* "typeset" may take a numeric argument at the tail of the
! 		   options */
! 		if (idigit(*arg) && (flags & BINF_TYPEOPT)) {
! 		    char* endPtr;
! 		    auxlen = (int)strtol(arg, &endPtr, 10);
! 		    arg = endPtr;
! 		}
! 		if (*arg) {
! 		    zerr("bad option: %c", NULL, *arg);
! 		    zsfree(xarg);
! 		    return 1;
! 		}
  	    }
  	    /* handle the special "set" options */
  	    arg = (char *) ugetnode(args);

SUZUKI Hisao		# `Begin at the beginning and go on till
suzuki@xxxxxxxxxxxxxx	# you come to the end:  then stop.'




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