zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: Re: missing -o kshautoload checks
@ 2000-08-01 14:23 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 2000-08-01 14:23 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Aug 1, 10:25am, Sven Wischnowsky wrote:
> } 
> } Bart Schaefer wrote:
> } 
> } > ...
> } > 
> } > I haven't actually tried it, but I'm pretty sure that if you `zcompile -z'
> } > a file that ends with `[[ -o kshautoload ]] && $0 "$@"', and you have
> } > kshautoload set, you'll end up executing the function *twice* the first
> } > time it's autoloaded.
> } 
> } No, it is *not* executed on the first call. Ok, it is executed, but
> } one won't see that because it only redefines itself (and any helper
> } functions).
> 
> I think you're wrong, but it's because I've tricked you with a typo.

;-) Right.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: Re: missing -o kshautoload checks
  2000-08-01  8:25 Sven Wischnowsky
@ 2000-08-01 14:15 ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-08-01 14:15 UTC (permalink / raw)
  To: zsh-workers

On Aug 1, 10:25am, Sven Wischnowsky wrote:
} 
} Bart Schaefer wrote:
} 
} > ...
} > 
} > I haven't actually tried it, but I'm pretty sure that if you `zcompile -z'
} > a file that ends with `[[ -o kshautoload ]] && $0 "$@"', and you have
} > kshautoload set, you'll end up executing the function *twice* the first
} > time it's autoloaded.
} 
} No, it is *not* executed on the first call. Ok, it is executed, but
} one won't see that because it only redefines itself (and any helper
} functions).

I think you're wrong, but it's because I've tricked you with a typo.

The usual idiom is `[[ -o kshautoload ]] || $0 "$@"', but I wrote `&&'.

With && zsh will execute the function, because kshautoload does *not*
become temporarily unset just because the function is loaded with zsh
semantics.  However, the first execution just harmlessly redefines the
function, so you won't notice.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* PATCH: Re: missing -o kshautoload checks
@ 2000-08-01  8:25 Sven Wischnowsky
  2000-08-01 14:15 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2000-08-01  8:25 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> I haven't actually tried it, but I'm pretty sure that if you `zcompile -z'
> a file that ends with `[[ -o kshautoload ]] && $0 "$@"', and you have
> kshautoload set, you'll end up executing the function *twice* the first
> time it's autoloaded.  So really we should be *removing* all the checks
> for kshautoload, not adding more of them.

No, it is *not* executed on the first call. Ok, it is executed, but
one won't see that because it only redefines itself (and any helper
functions).


I have to apologise for not removing the kshautoload tests when I
added the `zcompile -z' description.

The hunk in exec.c fixes a real bug: with a function that redefines
itself we can't use the old shfunc structure to get the name to store
in scriptname.

Bye
 Sven

Index: Completion/Bsd/_bsd_pkg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Bsd/_bsd_pkg,v
retrieving revision 1.2
diff -u -r1.2 _bsd_pkg
--- Completion/Bsd/_bsd_pkg	2000/05/16 16:21:33	1.2
+++ Completion/Bsd/_bsd_pkg	2000/08/01 08:24:01
@@ -65,4 +65,4 @@
   esac
 }
 
-[[ -o kshautoload ]] || _bsd_pkg "$@"
+_bsd_pkg "$@"
Index: Completion/Bsd/_kld
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Bsd/_kld,v
retrieving revision 1.1
diff -u -r1.1 _kld
--- Completion/Bsd/_kld	2000/04/20 09:45:04	1.1
+++ Completion/Bsd/_kld	2000/08/01 08:24:01
@@ -38,4 +38,4 @@
   esac
 }
 
-[[ -o kshautoload ]] || _kld "$@"
+_kld "$@"
Index: Completion/Commands/_next_tags
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_next_tags,v
retrieving revision 1.7
diff -u -r1.7 _next_tags
--- Completion/Commands/_next_tags	2000/06/07 06:47:40	1.7
+++ Completion/Commands/_next_tags	2000/08/01 08:24:01
@@ -138,4 +138,4 @@
   fi
 }
 
-[[ -o kshautoload ]] || _next_tags "$@"
+_next_tags "$@"
Index: Completion/User/_cvs
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_cvs,v
retrieving revision 1.11
diff -u -r1.11 _cvs
--- Completion/User/_cvs	2000/07/20 16:13:21	1.11
+++ Completion/User/_cvs	2000/08/01 08:24:01
@@ -817,4 +817,4 @@
   }
 }
 
-[[ -o kshautoload ]] || _cvs "$@"
+_cvs "$@"
Index: Completion/User/_mailboxes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_mailboxes,v
retrieving revision 1.4
diff -u -r1.4 _mailboxes
--- Completion/User/_mailboxes	2000/06/22 04:11:35	1.4
+++ Completion/User/_mailboxes	2000/08/01 08:24:01
@@ -175,4 +175,4 @@
   return ret
 }
 
-[[ -o kshautoload ]] || _mailboxes "$@"
+_mailboxes "$@"
Index: Completion/X/_xset
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/_xset,v
retrieving revision 1.3
diff -u -r1.3 _xset
--- Completion/X/_xset	2000/05/06 07:59:53	1.3
+++ Completion/X/_xset	2000/08/01 08:24:01
@@ -195,4 +195,4 @@
   _xset_parse
 }
 
-[[ -o kshautoload ]] || _xset "$@"
+_xset "$@"
Index: Completion/X/_xwit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/_xwit,v
retrieving revision 1.5
diff -u -r1.5 _xwit
--- Completion/X/_xwit	2000/05/06 07:59:53	1.5
+++ Completion/X/_xwit	2000/08/01 08:24:01
@@ -173,4 +173,4 @@
   _xwit_parse
 }
 
-[[ -o kshautoload ]] || _xwit "$@"
+_xwit "$@"
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.14
diff -u -r1.14 exec.c
--- Src/exec.c	2000/07/27 17:48:48	1.14
+++ Src/exec.c	2000/08/01 08:24:02
@@ -3189,7 +3189,7 @@
 	return 1;
 
     oldscriptname = scriptname;
-    scriptname = dupstring(state->prog->shf->nam);
+    scriptname = dupstring(shf->nam);
     execode(shf->funcdef, 1, 0);
     scriptname = oldscriptname;
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

end of thread, other threads:[~2000-08-01 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-01 14:23 PATCH: Re: missing -o kshautoload checks Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-08-01  8:25 Sven Wischnowsky
2000-08-01 14:15 ` Bart Schaefer

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