From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: zsh-workers@sunsite.dk
Subject: [PATCH] Proposal: stat -> zstat
Date: Wed, 2 May 2007 22:39:52 -0700 [thread overview]
Message-ID: <20070503053952.GA1481@redoubt.spodhuis.org> (raw)
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"
next reply other threads:[~2007-05-03 5:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-03 5:39 Phil Pennock [this message]
2007-05-03 8:50 ` Peter Stephenson
2007-05-06 1:07 ` Phil Pennock
2007-05-06 11:57 ` Peter Stephenson
2007-05-06 14:00 ` Phil Pennock
2007-05-07 0:58 ` Peter Stephenson
2007-05-03 14:48 ` Bart Schaefer
2007-05-03 15:46 ` Peter Stephenson
2007-05-07 5:31 ` Bart Schaefer
2007-05-08 14:40 ` Peter Stephenson
2007-05-09 17:19 ` Bart Schaefer
2007-05-09 17:47 ` Peter Stephenson
2012-06-29 9:40 4.3.17 unset RPS1 vs RPROMPT Phil Pennock
2012-06-29 10:02 ` Mikael Magnusson
2012-06-29 13:32 ` Phil Pennock
2012-06-29 17:35 ` Bart Schaefer
2012-06-29 18:52 ` Peter Stephenson
2012-06-30 5:05 ` Phil Pennock
2012-06-30 17:31 ` Bart Schaefer
2012-07-01 17:39 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070503053952.GA1481@redoubt.spodhuis.org \
--to=zsh-workers+phil.pennock@spodhuis.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).