zsh-workers
 help / color / mirror / code / Atom feed
* 4.3.17 unset RPS1 vs RPROMPT
@ 2012-06-29  9:40 Phil Pennock
  2012-06-29 10:02 ` Mikael Magnusson
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Phil Pennock @ 2012-06-29  9:40 UTC (permalink / raw)
  To: zsh-workers

zsh 4.3.17, multiple OSes.

Using "prompt walters", I get a green right-prompt.
Using "prompt pdp" to invoke my own setup, I still have it.
I debug.  I have "unset RPS1" in my setup function.
Strange, try at command-line.

 unset RPS1       # no effect
 unset RPROMPT    # works

I see Src/params.c:
IPDEF7("RPS1", &rprompt),
IPDEF7("RPROMPT", &rprompt),

and I know that the docs claim them equivalent.

So try with "zsh -f", and it works.  Some debugging later, and I find
that if I "unset RPS1" then "typeset -p RPS1 RPROMPT" shows just
RPROMPT, not both.  If I then call "prompt walters", then RPROMPT will
be set and can only be cleared with "unset RPROMPT".

If I also "unset RPROMPT", then it comes back into being as a magic
variable during prompt setup.  If I assign to RPS1, then it too comes
back as a magic variable bound to the same internal rprompt.

Is it expected that RPROMPT and RPS1 can be decoupled in this way?
Is there a correct way to clear the prompt, other than *always* having
to do "unset RPROMPT RPS1" because one or the other may have become
decoupled?

I don't see it documented and it seems very strange to me.  I'd expect
that if one is unset, the rprompt content gets unset, but assigning to
either would instantiate the other again, since it can't be reused by a
user anyway -- if they unset and then assign to a new value, it still
changes the same C level "rprompt" variable.

Thoughts?
-Phil


^ permalink raw reply	[flat|nested] 20+ messages in thread
* [PATCH] Proposal: stat -> zstat
@ 2007-05-03  5:39 Phil Pennock
  2007-05-03  8:50 ` Peter Stephenson
  2007-05-03 14:48 ` Bart Schaefer
  0 siblings, 2 replies; 20+ messages in thread
From: Phil Pennock @ 2007-05-03  5:39 UTC (permalink / raw)
  To: zsh-workers

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"


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-07-01 18:07 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2007-05-03  5:39 [PATCH] Proposal: stat -> zstat Phil Pennock
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

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).