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

[PATCH] Proposal: stat -> zstat



Since a stat external command has become popular, perhaps it's worth zsh
4.4 migrating users towards using zstat as a builtin?  Then turn off
stat somewhere around zsh 6 ... *cough*

Also, by having two builtins which can be independently disabled, the
{...} always {...} stuff from zcalsys becomes thankfully unnecessary.

I was thinking of making stat be a function wrapper, but I suspect that
some people may have scripts using "command stat" vs "builtin stat".

Thoughts?

diff -urp zsh-head/Doc/Zsh/builtins.yo zsh-zstat/Doc/Zsh/builtins.yo
--- zsh-head/Doc/Zsh/builtins.yo	Fri Mar 23 10:14:05 2007
+++ zsh-zstat/Doc/Zsh/builtins.yo	Wed May  2 22:30:21 2007
@@ -2014,6 +2014,7 @@ module(zprof)(zsh/zprof)
 module(zpty)(zsh/zpty)
 module(zregexparse)(zsh/zutil)
 module(zsocket)(zsh/net/socket)
+module(zstat)(zsh/stat)
 module(zstyle)(zsh/zutil)
 module(ztcp)(zsh/net/tcp)
 enditem()
diff -urp zsh-head/Doc/Zsh/calsys.yo zsh-zstat/Doc/Zsh/calsys.yo
--- zsh-head/Doc/Zsh/calsys.yo	Mon Mar 26 07:33:33 2007
+++ zsh-zstat/Doc/Zsh/calsys.yo	Wed May  2 22:05:35 2007
@@ -466,8 +466,9 @@ findex(age)
 The function tt(age) can be autoloaded and use separately from
 the calendar system, although it uses the function tt(calendar_scandate)
 for date formatting.  It requires the tt(zsh/stat) builtin, which
-makes available the builtin tt(stat).  This may conflict with an
-external programme of the same name; if it does, the builtin may be
+makes available the builtin tt(zstat).   This currently still provides
+the old name tt(stat) which may conflict with an
+external programme of that same name; if it does, the builtin may be
 disabled for normal operation by including the following code in
 an initialization file:
 
diff -urp zsh-head/Doc/Zsh/mod_stat.yo zsh-zstat/Doc/Zsh/mod_stat.yo
--- zsh-head/Doc/Zsh/mod_stat.yo	Fri Apr  7 13:07:10 2000
+++ zsh-zstat/Doc/Zsh/mod_stat.yo	Wed May  2 22:29:19 2007
@@ -1,13 +1,28 @@
 COMMENT(!MOD!zsh/stat
 A builtin command interface to the tt(stat) system call.
 !MOD!)
-The tt(zsh/stat) module makes available one builtin command:
+The tt(zsh/stat) module makes available two builtin commands which are
+the same internally.
 
 startitem()
 findex(stat)
+item(tt(stat) ...)(
+This is identical to tt(zstat) but use of the name tt(stat) is deprecated.
+As the years have passed, an external command named tt(stat) has appeared
+with incompatible output.  Zsh has renamed its tt(stat) to tt(zstat) and
+is currently maintaining the old name for backwards compatibility.
+When writing scripts, please use tt(zstat).  One day, zsh will remove
+its tt(stat) builtin; in the meantime, you can disable the tt(stat) name
+whilst keeping tt(zstat) with the command:
+
+example(disable stat)
+)
+
+startitem()
+findex(zstat)
 cindex(files, listing)
 cindex(files, examining)
-item(tt(stat) [ tt(-gnNolLtTrs) ] [ tt(-f) var(fd) ] \
+item(tt(zstat) [ tt(-gnNolLtTrs) ] [ tt(-f) var(fd) ] \
     [ tt(-H) var(hash) ] [ tt(-A) var(array) ] \
     [ tt(-F) var(fmt) ] [ tt(PLUS())var(element) ] [ var(file) ... ])(
 The command acts as a front end to the tt(stat) system call (see
diff -urp zsh-head/Functions/Calendar/age zsh-zstat/Functions/Calendar/age
--- zsh-head/Functions/Calendar/age	Mon Dec  4 02:59:11 2006
+++ zsh-zstat/Functions/Calendar/age	Wed May  2 22:17:51 2007
@@ -27,24 +27,16 @@
 # any argument is passed in the first format.
 
 emulate -L zsh
-integer mystat disable_stat
+integer mystat
 
 zmodload -i zsh/stat
-# Allow the builtin stat to be hidden.
-zmodload -i zsh/parameter
-
-{
-if [[ $builtins[stat] != defined ]]; then
-  (( disable_stat = 1 ))
-  enable stat
-fi
 
 autoload -U calendar_scandate
 
 local -a vals
 
 [[ -e $REPLY ]] || return 1
-stat -A vals +mtime $REPLY || return 1
+zstat -A vals +mtime $REPLY || return 1
 
 if (( $# >= 1 )); then
   local AGEREF=$1
@@ -77,9 +69,6 @@ else
   mystat=1
 fi
 
-} always {
-# If the builtin stat was previously disabled, disable it again.
-(( disable_stat )) && disable stat
 }
 
 return $mystat
diff -urp zsh-head/Functions/Example/zls zsh-zstat/Functions/Example/zls
--- zsh-head/Functions/Example/zls	Mon Apr  2 05:29:06 2001
+++ zsh-zstat/Functions/Example/zls	Wed May  2 22:19:12 2007
@@ -49,7 +49,7 @@ fi
 
 for f in $*
 do
-    stat -s$L -H stat -F "%b %e %H:%M" - $f || continue
+    zstat -s$L -H stat -F "%b %e %H:%M" - $f || continue
     if [[ $opts != *d* && $stat[mode] == d* ]] then
 	dirs=( $dirs $f )
     elif [[ $opts == *l* ]] then
diff -urp zsh-head/Src/Modules/stat.c zsh-zstat/Src/Modules/stat.c
--- zsh-head/Src/Modules/stat.c	Tue May 30 15:35:03 2006
+++ zsh-zstat/Src/Modules/stat.c	Wed May  2 22:00:36 2007
@@ -620,6 +620,7 @@ bin_stat(char *name, char **args, Option
 }
 
 static struct builtin bintab[] = {
+    BUILTIN("zstat", 0, bin_stat, 0, -1, 0, NULL, NULL),
     BUILTIN("stat", 0, bin_stat, 0, -1, 0, NULL, NULL),
 };
 
diff -urp zsh-head/Src/Modules/stat.mdd zsh-zstat/Src/Modules/stat.mdd
--- zsh-head/Src/Modules/stat.mdd	Sun Nov 26 12:01:03 2000
+++ zsh-zstat/Src/Modules/stat.mdd	Wed May  2 22:19:56 2007
@@ -2,6 +2,6 @@ name=zsh/stat
 link=dynamic
 load=no
 
-autobins="stat"
+autobins="stat zstat"
 
 objects="stat.o"



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