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

Re: ZSH's future [longish] ?



> ...
> Shell), and is intended to conform to the IEEE P1003.2/ISO 9945.2
> Shell and Utilities standard. KSH-93 provides an enhanced programming
> ...

I think zsh is mostly POSIX compatible.  I think it would not be difficult to
improve POSIX compatibility without affectin present features.  I already did
some work for it and I use zsh as /bin/sh for more than a half year now
without problems.

> environment in addition to the major command-entry features of the BSD
> shell "csh". With KSH-93, medium-sized programming tasks can be
> performed at shell-level without a significant loss in performance. In
> addition, "sh" scripts can be run on KSH-93 without modification.

I use zsh for these medium-sized programming staff.  It is very poverfull, and
it has the advantage that it is free and I can compile zsh on any machine I
have (there are 7 different unices here).

> The code should conform to the IEEE POSIX 1003.1 standard and to the
> proposed ANSI-C standard so that it should be portable to all such

Thanks to Richard, zsh is one of the most portable program I've ever seen.  I
think ksh could'n beat it.

> systems. Like the previous version, KSH-88, it is designed to accept
> eight bit character sets transparently, thereby making it
> internationally compatible. It can support multi-byte characters sets
> with some characteristics of the character set given at run time.

This is a weak point in zsh, since it has problems with character codes
between 128 and 159.  This is not really a big broblem sine this code range is
not usually used for printable characters.  Multibyte character support is
completely missing.  I may try to do something for these sometime (but I
probably won't do anything before next summer).

History features of zsh are quite good I think (except some bugs in the
baseline which I fixed long ago), and command line editing is unbeatable.
Same for the I/O capabilities.  Performance is also pretty good although I did
not compared with ksh.

The only thing missing from zsh's arithmetic capabilities is floating point
arithmetic.  The vanilla version may also have problems with indexed arrays in
arithmetic expressions and assignments inside $((...)) substitutions.

>     o Arrays: KSH-93 supports both indexed and associative arrays. The
>       subscript for an indexed array is an arithmetic expression,
>       whereas, the subscript for an associative array is a string.

I think zsh provides all of these array features.  Some of this code is broken
in the baseline version, but I fixed these problems long ago.

>     o Substring Capabilities: KSH-93 allows you to create a substring
>       of any given string either by specifying the starting offset and
>       length, or by stripping off leading or trailing substrings
>       during parameter substitution. You can also specify attributes,
>       such as upper and lower case, field width, and justification to
>       shell variables.

Zsh can handle substrings perfectly and the variable expansion features are
excelent.  Unfortunately the baseline release have some bugs here but I fixed
these bugs log ago.

>     o More pattern matching capabilities: KSH-93 allows you to specify
>       extended regular expressions for file and string matches.

Zsh glob patterns can do anything that an extended regular expression can do.
This syntax is different but I think this is not really a big problem.  A
bonus with zsh that it can use exclude patterns and file modes for globing and
supports qualifiers.

>     o KSH-93 uses a hierarchal name space for variables. Compound
>       variables can be defined and variables can be passed by
>       reference. In addition, each variable can have one or more
>       disciplines associated with it to intercept assignments and
>       references.
> 
>     o Improved debugging: KSH-93 can generate line numbers on
>       execution traces. Also, I/O redirections are now traced. There
>       is a DEBUG trap that gets evaluated after each command so that
>       errors can be localized.

These seems to be missing from zsh.  An especially week point of zsh is
special variable handling.

Job control is fully functional in zsh.

>     o Added security: KSH-93 can execute scripts which do not have
>       read permission and scripts which have the setuid and/or setgid
>       set when invoked by name, rather than as an argument to the
>       shell. It is possible to log or control the execution of setuid
>       and/or setgid scripts. The noclobber option prevents you from
>       accidentally erasing a file by redirecting to an existing file.

These features are already in zsh, or can be added if necessary.  When zsh
invoked as setuid, it disables user startup/shutdown files.  I think it would
be reasonable to source an additional suid_zprofile when invoked as a suid
script (as it is already done when invoked as sh/ksh).

>     o KSH-93 can be extended by adding built-in commands at run
>       time. In addition, KSH-93 can be used as a library that can be
>       embedded into an application to allow scripting.

That would be nice in zsh as well.  It may help to keep zsh a small shell and
load feature modules on-demand.  E.g.  I often write complicated scripts with
zsh where the whole zle staff is not needed.

To summarize my opinion, zsh is at least as good as ksh.  It has outstanding
interactive capabilities with advanced features completely missing from ksh.
But it can also be used as a powerful script language.  An example: with my
releases the expansion of ${${(f)$(</etc/group)}%%:*} gives the list of the
group names from /etc/groups.  With ksh you would have to write $(cat -d: -f1
/etc/group) which may look nicer but requires an expensive fork and exec.

With zsh using this kind of nested expansion almost anything can be done.
This, together with the extended globbing (using file type/date/owner/length
etc) makes zsh an extremely powerful script language.  The problem is that
most of the zsh users are not aware of these capabilities.  A good and
easy-to-understand zsh book would help a lot.

Cheers,
  Zoltan



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