zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Add `sourcetrace' option
       [not found]   ` <4B58AB3A.7050300@mycircuit.org>
@ 2010-01-23 10:18     ` Frank Terbeck
  2010-01-23 15:46       ` Baptiste Daroussin
                         ` (2 more replies)
       [not found]     ` <m3fx5y2le2.fsf@klanderman.net>
       [not found]     ` <2d3b879b1001211336m5b78982au96f267ea472af43d@mail.gmail.com>
  2 siblings, 3 replies; 20+ messages in thread
From: Frank Terbeck @ 2010-01-23 10:18 UTC (permalink / raw)
  To: zsh-workers; +Cc: vmail, ft

Peter wrote:
> Is there a way to list the files that the shell has read on startup?

With this patch, you can invoke zsh like this:
    % zsh -o sourcetrace

to make zsh tell you which files it sources right before it does. That
would catch all the files, that are read upon startup, too.

I don't know how much sense it would make to make this part of zsh in
this or another form; but this was easy enough, so no time wasted.

Regards, Frank

---
 Doc/Zsh/options.yo |    8 ++++++++
 Src/init.c         |    5 +++++
 Src/options.c      |    1 +
 Src/zsh.h          |    1 +
 4 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 8c11c82..e19a58a 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1584,6 +1584,14 @@ Sequences of digits indicating a numeric base such as the `tt(08)'
 component in `tt(08#77)' are always interpreted as decimal, regardless
 of leading zeroes.
 )
+pindex(SOURCE_TRACE)
+pindex(NO_SOURCE_TRACE)
+pindex(SOURCETRACE)
+pindex(NOSOURCETRACE)
+item(tt(SOURCE_TRACE))(
+If set, when sourcing a file zsh will print a message about which file
+it is about to source.
+)
 pindex(TYPESET_SILENT)
 pindex(NO_TYPESET_SILENT)
 pindex(TYPESETSILENT)
diff --git a/Src/init.c b/Src/init.c
index 123e20e..c59d632 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1102,6 +1102,11 @@ source(char *s)
 	return SOURCE_NOT_FOUND;
     }
 
+    if (isset(SOURCETRACE)) {
+	fprintf(stderr, "sourcetrace> \"%s\"\n", s);
+	fflush(stderr);
+    }
+
     /* save the current shell state */
     fd        = SHIN;            /* store the shell input fd                  */
     obshin    = bshin;          /* store file handle for buffered shell input */
diff --git a/Src/options.c b/Src/options.c
index a5f299e..7055466 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -233,6 +233,7 @@ static struct optname optns[] = {
 {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
 {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
 {{NULL, "singlelinezle",      OPT_KSH},			 SINGLELINEZLE},
+{{NULL, "sourcetrace",        0},			 SOURCETRACE},
 {{NULL, "sunkeyboardhack",    0},			 SUNKEYBOARDHACK},
 {{NULL, "transientrprompt",   0},			 TRANSIENTRPROMPT},
 {{NULL, "trapsasync",	      0},			 TRAPSASYNC},
diff --git a/Src/zsh.h b/Src/zsh.h
index 060f8a6..f2bab06 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1999,6 +1999,7 @@ enum {
     SHWORDSPLIT,
     SINGLECOMMAND,
     SINGLELINEZLE,
+    SOURCETRACE,
     SUNKEYBOARDHACK,
     TRANSIENTRPROMPT,
     TRAPSASYNC,
-- 
1.6.6.rc1.31.g1a56b


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

* Re: what is the effect of a percentage sign (%) as last character on  the command line
       [not found]               ` <14989d6e1001230228k22e32200s10db146bd8596dc2@mail.gmail.com>
@ 2010-01-23 12:03                 ` Peter
  0 siblings, 0 replies; 20+ messages in thread
From: Peter @ 2010-01-23 12:03 UTC (permalink / raw)
  To: Christian Walther, zsh-workers


> If you need to debug your configuration it is pretty save to just send
> the name of the current file to stdout, e.g. by adding a echo to the
> beginning of each file. You can even do this conditionally, for
> example by adding
>
> export CONFIGDEBUG=true
>
> to /etc/zshenv if you're root on this machine, or to ~/.zshenv.
>
> And then you add something like
>
> [[ -n $CONFIGDEBUG ]]&&  echo "Reading:<filename>"
>
> to each file. This way, you see what's happening and it's still easy
> to disable the output.
>
>    
This seems to be a nice and easy solution, thanks !
Peter


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

* Re: PATCH: Add `sourcetrace' option
  2010-01-23 10:18     ` PATCH: Add `sourcetrace' option Frank Terbeck
@ 2010-01-23 15:46       ` Baptiste Daroussin
  2010-01-23 20:16       ` Richard Hartmann
  2010-01-24  9:21       ` Peter
  2 siblings, 0 replies; 20+ messages in thread
From: Baptiste Daroussin @ 2010-01-23 15:46 UTC (permalink / raw)
  To: zsh-workers

Le Saturday 23 Jan 2010 à 11:18:02 (+0100), Frank Terbeck a écrit :
> Peter wrote:
> > Is there a way to list the files that the shell has read on startup?
> 
> With this patch, you can invoke zsh like this:
>     % zsh -o sourcetrace
> 

I'd love to see that feature integrated into zsh. Thanks for this patch

regards,
--
Bapt


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

* Re: PATCH: Add `sourcetrace' option
  2010-01-23 10:18     ` PATCH: Add `sourcetrace' option Frank Terbeck
  2010-01-23 15:46       ` Baptiste Daroussin
@ 2010-01-23 20:16       ` Richard Hartmann
  2010-01-23 21:53         ` PATCH: " Frank Terbeck
  2010-01-24  9:21       ` Peter
  2 siblings, 1 reply; 20+ messages in thread
From: Richard Hartmann @ 2010-01-23 20:16 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-workers, vmail

On Sat, Jan 23, 2010 at 11:18, Frank Terbeck <ft@bewatermyfriend.org> wrote:

> +If set, when sourcing a file zsh will print a message about which file
> +it is about to source.

Suggestion for alternative wording:

If set, zsh will print a debug message for each file it is about to source.


Fwiw, I agree that this would be useful.


Richard


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

* PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 20:16       ` Richard Hartmann
@ 2010-01-23 21:53         ` Frank Terbeck
  2010-01-23 22:07           ` Benjamin R. Haskell
  2010-01-23 22:14           ` PATCH: " Frank Terbeck
  0 siblings, 2 replies; 20+ messages in thread
From: Frank Terbeck @ 2010-01-23 21:53 UTC (permalink / raw)
  To: zsh-workers; +Cc: richih.mailinglist, ft

Peter wrote:
> Is there a way to list the files that the shell has read on startup?

With this patch, you can invoke zsh like this:
    % zsh -o sourcetrace

to make zsh tell you which files it sources right before it does. That
would catch all the files, that are read upon startup, too.

Richard Hartmann <richih.mailinglist@gmail.com> wrote:
> Frank Terbeck <ft@bewatermyfriend.org> wrote:
>> +If set, when sourcing a file zsh will print a message about which file
>> +it is about to source.
>
> Suggestion for alternative wording:
>
> If set, zsh will print a debug message for each file it is about to source.

I agree. My initial wording wasn't well thought out. But I'm not
entirely happy with this suggestion either. For one thing, the messages
are not strictly for `debugging' (although that may be a valid use
case), they are merely informational.

Here's an updated patch. I'm happy with the way the documentation reads
now.

Regards, Frank
---
 Doc/Zsh/options.yo |   10 ++++++++++
 Src/init.c         |    5 +++++
 Src/options.c      |    1 +
 Src/zsh.h          |    1 +
 4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 8c11c82..4f57e23 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1584,6 +1584,16 @@ Sequences of digits indicating a numeric base such as the `tt(08)'
 component in `tt(08#77)' are always interpreted as decimal, regardless
 of leading zeroes.
 )
+pindex(SOURCE_TRACE)
+pindex(NO_SOURCE_TRACE)
+pindex(SOURCETRACE)
+pindex(NOSOURCETRACE)
+item(tt(SOURCE_TRACE))(
+If set, zsh will print an informational message announcing the name of
+each file loads.  A file may be loaded by the shell itself when it
+starts up and shuts down (tt(Startup/Shutdown Files)) or by the use of
+the `tt(source)' and `tt(dot)' builtin commands.
+)
 pindex(TYPESET_SILENT)
 pindex(NO_TYPESET_SILENT)
 pindex(TYPESETSILENT)
diff --git a/Src/init.c b/Src/init.c
index 123e20e..c59d632 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1102,6 +1102,11 @@ source(char *s)
 	return SOURCE_NOT_FOUND;
     }
 
+    if (isset(SOURCETRACE)) {
+	fprintf(stderr, "sourcetrace> \"%s\"\n", s);
+	fflush(stderr);
+    }
+
     /* save the current shell state */
     fd        = SHIN;            /* store the shell input fd                  */
     obshin    = bshin;          /* store file handle for buffered shell input */
diff --git a/Src/options.c b/Src/options.c
index a5f299e..7055466 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -233,6 +233,7 @@ static struct optname optns[] = {
 {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
 {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
 {{NULL, "singlelinezle",      OPT_KSH},			 SINGLELINEZLE},
+{{NULL, "sourcetrace",        0},			 SOURCETRACE},
 {{NULL, "sunkeyboardhack",    0},			 SUNKEYBOARDHACK},
 {{NULL, "transientrprompt",   0},			 TRANSIENTRPROMPT},
 {{NULL, "trapsasync",	      0},			 TRAPSASYNC},
diff --git a/Src/zsh.h b/Src/zsh.h
index 060f8a6..f2bab06 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1999,6 +1999,7 @@ enum {
     SHWORDSPLIT,
     SINGLECOMMAND,
     SINGLELINEZLE,
+    SOURCETRACE,
     SUNKEYBOARDHACK,
     TRANSIENTRPROMPT,
     TRAPSASYNC,
-- 
1.6.6.rc1.31.g1a56b


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

* Re: PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 21:53         ` PATCH: " Frank Terbeck
@ 2010-01-23 22:07           ` Benjamin R. Haskell
  2010-01-23 22:23             ` Frank Terbeck
  2010-01-23 22:14           ` PATCH: " Frank Terbeck
  1 sibling, 1 reply; 20+ messages in thread
From: Benjamin R. Haskell @ 2010-01-23 22:07 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-workers, richih.mailinglist

On Sat, 23 Jan 2010, Frank Terbeck wrote:

> Peter wrote:
> > Is there a way to list the files that the shell has read on startup?
> 
> With this patch, you can invoke zsh like this:
>     % zsh -o sourcetrace
> 
> [...]
> 
> Here's an updated patch. I'm happy with the way the documentation reads
> now.
> 
> Regards, Frank
> [...]
> 
> diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
> index 8c11c82..4f57e23 100644
> --- a/Doc/Zsh/options.yo
> +++ b/Doc/Zsh/options.yo
>  [...]
> +If set, zsh will print an informational message announcing the name of
> +each file loads.  A file may be loaded by the shell itself when it

Missed a word or two:

+If set, zsh will print an informational message announcing the name of
+each file it loads.  A file may be loaded by the shell itself when it
           ^^^

(or 'as it'?)

-- 
Best,
Ben


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

* Re: PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 21:53         ` PATCH: " Frank Terbeck
  2010-01-23 22:07           ` Benjamin R. Haskell
@ 2010-01-23 22:14           ` Frank Terbeck
  2010-01-23 23:44             ` Bart Schaefer
  1 sibling, 1 reply; 20+ messages in thread
From: Frank Terbeck @ 2010-01-23 22:14 UTC (permalink / raw)
  To: zsh-workers; +Cc: richih.mailinglist

Frank Terbeck writes:
[...]
> diff --git a/Src/init.c b/Src/init.c
> index 123e20e..c59d632 100644
> --- a/Src/init.c
> +++ b/Src/init.c
> @@ -1102,6 +1102,11 @@ source(char *s)
>  	return SOURCE_NOT_FOUND;
>      }
>  
> +    if (isset(SOURCETRACE)) {
> +	fprintf(stderr, "sourcetrace> \"%s\"\n", s);
> +	fflush(stderr);
> +    }
> +
>      /* save the current shell state */
>      fd        = SHIN;            /* store the shell input fd                  */
>      obshin    = bshin;          /* store file handle for buffered shell input */
[...]

Okay, this breaks menu selection for me...

I've got no idea what's going on. Needless to say, this patch is worth
nothing if it breaks other parts of the shell. The test suite seems to
pass just fine. But menu selection, as I said doesn't work anymore.

I'm really interested in why the code above blows up menu selection.
Anyone who knows what's going on, feel free to explain what the deal
is here.


Regards, Frank - puzzled.


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

* Re: PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 22:07           ` Benjamin R. Haskell
@ 2010-01-23 22:23             ` Frank Terbeck
  2010-01-23 23:46               ` Bart Schaefer
  0 siblings, 1 reply; 20+ messages in thread
From: Frank Terbeck @ 2010-01-23 22:23 UTC (permalink / raw)
  To: Benjamin R. Haskell; +Cc: zsh-workers, richih.mailinglist

Benjamin R. Haskell writes:
[...]
> Missed a word or two:
>
> +If set, zsh will print an informational message announcing the name of
> +each file it loads.  A file may be loaded by the shell itself when it
>            ^^^
>
> (or 'as it'?)

Well, I'm not a native speaker; so, if you say that `as it' sounds more
correct, that's probably true.

The way I understood `...as it does this-and-that...' was that it
denotes that something happens *during* the `this-and-that'. This option
however really just prints the name of each file it (as in the shell)
loads (actually right before it does, but that shouldn't be of any
importance).

If that's not the most idiomatic way to express this, I'm obviously open
for improvements. :-)

Regards, Frank


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

* Re: PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 22:14           ` PATCH: " Frank Terbeck
@ 2010-01-23 23:44             ` Bart Schaefer
  2010-01-24  0:05               ` Frank Terbeck
  0 siblings, 1 reply; 20+ messages in thread
From: Bart Schaefer @ 2010-01-23 23:44 UTC (permalink / raw)
  To: Frank Terbeck, zsh-workers

On Jan 23, 11:14pm, Frank Terbeck wrote:
} Subject: Re: PATCH: PATCH: Add `sourcetrace' option
}
} Frank Terbeck writes:
} Okay, this breaks menu selection for me...
} 
} I've got no idea what's going on.

You probably need a "make clean" and then rebuild -- any time you add
options, it's possible for the bit pattern of the option mask to be
changed and if everything that references it (such as modules) doesn't
get rebuilt, you will see odd behavior as options are misinterpreted.


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

* Re: PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 22:23             ` Frank Terbeck
@ 2010-01-23 23:46               ` Bart Schaefer
  2010-01-24  0:10                 ` Frank Terbeck
  0 siblings, 1 reply; 20+ messages in thread
From: Bart Schaefer @ 2010-01-23 23:46 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-workers

On Jan 23, 11:23pm, Frank Terbeck wrote:
} Subject: Re: PATCH: PATCH: Add `sourcetrace' option
}
} Benjamin R. Haskell writes:
} [...]
} > Missed a word or two:
} >
} > +If set, zsh will print an informational message announcing the name of
} > +each file it loads.  A file may be loaded by the shell itself when it
} >            ^^^
} >
} > (or 'as it'?)
} 
} Well, I'm not a native speaker; so, if you say that `as it' sounds more
} correct, that's probably true.

No, "it" rather than "as it" would be right here.  However, your patch
just said "file loads" so the "it" still needs to be inserted.


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

* Re: PATCH: Add `sourcetrace' option
  2010-01-23 23:44             ` Bart Schaefer
@ 2010-01-24  0:05               ` Frank Terbeck
  0 siblings, 0 replies; 20+ messages in thread
From: Frank Terbeck @ 2010-01-24  0:05 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer writes:
> On Jan 23, 11:14pm, Frank Terbeck wrote:
>} Okay, this breaks menu selection for me...
>} 
>} I've got no idea what's going on.
>
> You probably need a "make clean" and then rebuild -- any time you add
> options, it's possible for the bit pattern of the option mask to be
> changed and if everything that references it (such as modules) doesn't
> get rebuilt, you will see odd behavior as options are misinterpreted.

Well, I did do a 'make clean'. The important part is probably the part
about modules which are being referenced.  What I was doing was that I
ran the newly built zsh from my sandbox rather than installing it to my
system.

After installing the whole thing, it works as expected.
Thanks for pointing it out!

Regards, Frank


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

* Re: PATCH: PATCH: Add `sourcetrace' option
  2010-01-23 23:46               ` Bart Schaefer
@ 2010-01-24  0:10                 ` Frank Terbeck
  2010-01-24  0:18                   ` Frank Terbeck
  0 siblings, 1 reply; 20+ messages in thread
From: Frank Terbeck @ 2010-01-24  0:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer writes:
> On Jan 23, 11:23pm, Frank Terbeck wrote:
> } Benjamin R. Haskell writes:
> } [...]
> } > Missed a word or two:
> } >
> } > +If set, zsh will print an informational message announcing the name of
> } > +each file it loads.  A file may be loaded by the shell itself when it
> } >            ^^^
> } >
> } > (or 'as it'?)
> } 
> } Well, I'm not a native speaker; so, if you say that `as it' sounds more
> } correct, that's probably true.
>
> No, "it" rather than "as it" would be right here.  However, your patch
> just said "file loads" so the "it" still needs to be inserted.

Oh boy. I was *sure* I had it with the `it' in it. That's why I only
argued the 'as it'... Sorry about that.

I'll send an updated patch in a jiffy.

Regards, Frank


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

* PATCH: Add `sourcetrace' option
  2010-01-24  0:10                 ` Frank Terbeck
@ 2010-01-24  0:18                   ` Frank Terbeck
  2010-01-24 21:12                     ` Peter Stephenson
  0 siblings, 1 reply; 20+ messages in thread
From: Frank Terbeck @ 2010-01-24  0:18 UTC (permalink / raw)
  To: zsh-workers; +Cc: zsh, schaefer, richih.mailinglist, ft

Here's an updated patch. Thanks to everyone who reviewed the previous
attempts.

Regards, Frank
---
 Doc/Zsh/options.yo |   10 ++++++++++
 Src/init.c         |    5 +++++
 Src/options.c      |    1 +
 Src/zsh.h          |    1 +
 4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 8c11c82..3f1533f 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1584,6 +1584,16 @@ Sequences of digits indicating a numeric base such as the `tt(08)'
 component in `tt(08#77)' are always interpreted as decimal, regardless
 of leading zeroes.
 )
+pindex(SOURCE_TRACE)
+pindex(NO_SOURCE_TRACE)
+pindex(SOURCETRACE)
+pindex(NOSOURCETRACE)
+item(tt(SOURCE_TRACE))(
+If set, zsh will print an informational message announcing the name of
+each file it loads.  A file may be loaded by the shell itself when it
+starts up and shuts down (tt(Startup/Shutdown Files)) or by the use of
+the `tt(source)' and `tt(dot)' builtin commands.
+)
 pindex(TYPESET_SILENT)
 pindex(NO_TYPESET_SILENT)
 pindex(TYPESETSILENT)
diff --git a/Src/init.c b/Src/init.c
index 123e20e..c59d632 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1102,6 +1102,11 @@ source(char *s)
 	return SOURCE_NOT_FOUND;
     }
 
+    if (isset(SOURCETRACE)) {
+	fprintf(stderr, "sourcetrace> \"%s\"\n", s);
+	fflush(stderr);
+    }
+
     /* save the current shell state */
     fd        = SHIN;            /* store the shell input fd                  */
     obshin    = bshin;          /* store file handle for buffered shell input */
diff --git a/Src/options.c b/Src/options.c
index a5f299e..7055466 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -233,6 +233,7 @@ static struct optname optns[] = {
 {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
 {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
 {{NULL, "singlelinezle",      OPT_KSH},			 SINGLELINEZLE},
+{{NULL, "sourcetrace",        0},			 SOURCETRACE},
 {{NULL, "sunkeyboardhack",    0},			 SUNKEYBOARDHACK},
 {{NULL, "transientrprompt",   0},			 TRANSIENTRPROMPT},
 {{NULL, "trapsasync",	      0},			 TRAPSASYNC},
diff --git a/Src/zsh.h b/Src/zsh.h
index 060f8a6..f2bab06 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1999,6 +1999,7 @@ enum {
     SHWORDSPLIT,
     SINGLECOMMAND,
     SINGLELINEZLE,
+    SOURCETRACE,
     SUNKEYBOARDHACK,
     TRANSIENTRPROMPT,
     TRAPSASYNC,
-- 
1.6.6.rc1.31.g1a56b


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

* Re: PATCH: Add `sourcetrace' option
  2010-01-23 10:18     ` PATCH: Add `sourcetrace' option Frank Terbeck
  2010-01-23 15:46       ` Baptiste Daroussin
  2010-01-23 20:16       ` Richard Hartmann
@ 2010-01-24  9:21       ` Peter
  2 siblings, 0 replies; 20+ messages in thread
From: Peter @ 2010-01-24  9:21 UTC (permalink / raw)
  To: zsh-workers

On 01/23/2010 11:18 AM, Frank Terbeck wrote:
> Peter wrote:
>    
>> Is there a way to list the files that the shell has read on startup?
>>      
> With this patch, you can invoke zsh like this:
>      % zsh -o sourcetrace
>
> to make zsh tell you which files it sources right before it does. That
> would catch all the files, that are read upon startup, too.
>
> I don't know how much sense it would make to make this part of zsh in
> this or another form; but this was easy enough, so no time wasted.
>
> Regards, Frank
>
> ---
>   Doc/Zsh/options.yo |    8 ++++++++
>   Src/init.c         |    5 +++++
>   Src/options.c      |    1 +
>   Src/zsh.h          |    1 +
>   4 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
> index 8c11c82..e19a58a 100644
> --- a/Doc/Zsh/options.yo
> +++ b/Doc/Zsh/options.yo
> @@ -1584,6 +1584,14 @@ Sequences of digits indicating a numeric base such as the `tt(08)'
>   component in `tt(08#77)' are always interpreted as decimal, regardless
>   of leading zeroes.
>   )
> +pindex(SOURCE_TRACE)
> +pindex(NO_SOURCE_TRACE)
> +pindex(SOURCETRACE)
> +pindex(NOSOURCETRACE)
> +item(tt(SOURCE_TRACE))(
> +If set, when sourcing a file zsh will print a message about which file
> +it is about to source.
> +)
>   pindex(TYPESET_SILENT)
>   pindex(NO_TYPESET_SILENT)
>   pindex(TYPESETSILENT)
> diff --git a/Src/init.c b/Src/init.c
> index 123e20e..c59d632 100644
> --- a/Src/init.c
> +++ b/Src/init.c
> @@ -1102,6 +1102,11 @@ source(char *s)
>   	return SOURCE_NOT_FOUND;
>       }
>
> +    if (isset(SOURCETRACE)) {
> +	fprintf(stderr, "sourcetrace>  \"%s\"\n", s);
> +	fflush(stderr);
> +    }
> +
>       /* save the current shell state */
>       fd        = SHIN;            /* store the shell input fd                  */
>       obshin    = bshin;          /* store file handle for buffered shell input */
> diff --git a/Src/options.c b/Src/options.c
> index a5f299e..7055466 100644
> --- a/Src/options.c
> +++ b/Src/options.c
> @@ -233,6 +233,7 @@ static struct optname optns[] = {
>   {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
>   {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
>   {{NULL, "singlelinezle",      OPT_KSH},			 SINGLELINEZLE},
> +{{NULL, "sourcetrace",        0},			 SOURCETRACE},
>   {{NULL, "sunkeyboardhack",    0},			 SUNKEYBOARDHACK},
>   {{NULL, "transientrprompt",   0},			 TRANSIENTRPROMPT},
>   {{NULL, "trapsasync",	      0},			 TRAPSASYNC},
> diff --git a/Src/zsh.h b/Src/zsh.h
> index 060f8a6..f2bab06 100644
> --- a/Src/zsh.h
> +++ b/Src/zsh.h
> @@ -1999,6 +1999,7 @@ enum {
>       SHWORDSPLIT,
>       SINGLECOMMAND,
>       SINGLELINEZLE,
> +    SOURCETRACE,
>       SUNKEYBOARDHACK,
>       TRANSIENTRPROMPT,
>       TRAPSASYNC,
>    
Thanks a lot for the patch, this is exactly what I was looking for ...
Peter


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

* Re: what is the effect of a percentage sign (%) as last character on the command line
       [not found]             ` <100123155239.ZM27228@torch.brasslantern.com>
@ 2010-01-24  9:51               ` Peter
  2010-01-24 10:58                 ` Frank Terbeck
  0 siblings, 1 reply; 20+ messages in thread
From: Peter @ 2010-01-24  9:51 UTC (permalink / raw)
  To: zsh-workers


> I presume you had that somewhere interesting like inside your precmd
> or preexec function?  Just having it "in .zshrc" wouldn't affect any
> command except possibly the very first one.
>    
Yes, sorry , my snippet was too short:


git_info() {
   ref=$(git symbolic-ref -q HEAD 2>/dev/null)
   ref=${ref#refs/heads}
   echo ${ref:+"${GREEN}[$ref]${WHITE}"}

EXITCODE='%(?..(%?%))'
precmd () {
   PS1="%m%F{red}${EXITCODE}%f%# "
   RPROMPT="$(git_info)%30<..<%/"

   case $TERM in
     (xterm*|rxvt|mrxvt)
     print -Pn "\e]0;%n@%m: $1\a"
     ;;
   esac
}

And to follow your script hint ( with the erronous precmd version above ) :

$ date%
$(127)
$ script zsh.out
Script started, file is zsh.out
$ date%
zsh: command not found: date%
$ <CTRL-D>
Script done, file is zsh.out
$ cat zsh.out
Script started on Sun 24 Jan 2010 10:42:39 AM CET
$ date%
zsh: command not found: date%
$(127)

Script done on Sun 24 Jan 2010 10:43:06 AM CET
$ date%
$(127)

So apparently , the script program swallows the "dangling" control 
character and the shell behaves as expected ...

Peter


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

* Re: what is the effect of a percentage sign (%) as last character on the command line
  2010-01-24  9:51               ` Peter
@ 2010-01-24 10:58                 ` Frank Terbeck
  2010-01-24 14:50                   ` Peter
  2010-01-26  7:52                   ` Peter
  0 siblings, 2 replies; 20+ messages in thread
From: Frank Terbeck @ 2010-01-24 10:58 UTC (permalink / raw)
  To: Peter; +Cc: zsh-workers

Peter writes:
> Yes, sorry , my snippet was too short:
>
> git_info() {
>   ref=$(git symbolic-ref -q HEAD 2>/dev/null)
>   ref=${ref#refs/heads}
>   echo ${ref:+"${GREEN}[$ref]${WHITE}"}
[...]

Since you're trying to collect information from version control systems,
if you're on zsh 4.3.7 or newer, zsh includes a collection of functions
called `vcs_info' which do all the work for you. The thing is pretty
configurable, so tweaking it to your liking shouldn't be an issue.

It has support for a great number of version control systems; git is
among them (and the git backend is probably the one with the most
features).

If `vcs_info' is included in your zsh version, this should get you to
its documentation:
    % MANPAGER='less -M -p GATHER' man zshcontrib

Regards, Frank


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

* Re: what is the effect of a percentage sign (%) as last character on the command line
  2010-01-24 10:58                 ` Frank Terbeck
@ 2010-01-24 14:50                   ` Peter
  2010-01-26  7:52                   ` Peter
  1 sibling, 0 replies; 20+ messages in thread
From: Peter @ 2010-01-24 14:50 UTC (permalink / raw)
  To: zsh-workers


> If `vcs_info' is included in your zsh version, this should get you to
> its documentation:
>      % MANPAGER='less -M -p GATHER' man zshcontrib
>
> Regards, Frank
>    
Thanks, Frank , for the hint. In fact, I tried to use vcs_info when I 
started to configure my zsh but I just couldn't make it behave exactly 
as I wanted and finally I found it easier to write a small simple thing 
myself. Sometimes zsh configuration is just too much for a humble 
programmer (:-


Peter


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

* Re: PATCH: Add `sourcetrace' option
  2010-01-24  0:18                   ` Frank Terbeck
@ 2010-01-24 21:12                     ` Peter Stephenson
  2010-01-24 22:27                       ` Frank Terbeck
  0 siblings, 1 reply; 20+ messages in thread
From: Peter Stephenson @ 2010-01-24 21:12 UTC (permalink / raw)
  To: zsh-workers; +Cc: zsh, schaefer, richih.mailinglist

On Sun, 24 Jan 2010 01:18:16 +0100
Frank Terbeck <ft@bewatermyfriend.org> wrote:
> Here's an updated patch. Thanks to everyone who reviewed the previous
> attempts.

I'm just toying with this variant...  the difference is this moves the
output down until after the script name etc. is set up, and uses PS4
(like the xtrace option), so the output is more configurable.  For
example, I get:

+/etc/zshenv:1> <sourcetrace>
+/home/pws/.zshenv:1> <sourcetrace>
+/home/pws/.profile:1> <sourcetrace>
+/home/pws/.zshrc:1> <sourcetrace>
/home/pws/.aliasrc:1:> <sourcetrace>
/home/pws/.compinstall:1:> <sourcetrace>
/home/pws/.zcompdump_4.3.10-dev-1_pws:1:> <sourcetrace>

(the change in the middle is because I tweak PS4 to remove the "+" in
.zshrc, for no good reason I can now think of, as well as adding %_, and
there's only one global file because .zshenv sets NO_GLOBAL_RCS.)

I'm not particularly set on this but it seems more powerful without
losing anything obvious.  The documentation would need tweaking.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.88
diff -u -r1.88 options.yo
--- Doc/Zsh/options.yo	13 Jan 2010 12:05:48 -0000	1.88
+++ Doc/Zsh/options.yo	24 Jan 2010 21:10:31 -0000
@@ -1584,6 +1584,16 @@
 component in `tt(08#77)' are always interpreted as decimal, regardless
 of leading zeroes.
 )
+pindex(SOURCE_TRACE)
+pindex(NO_SOURCE_TRACE)
+pindex(SOURCETRACE)
+pindex(NOSOURCETRACE)
+item(tt(SOURCE_TRACE))(
+If set, zsh will print an informational message announcing the name of
+each file it loads.  A file may be loaded by the shell itself when it
+starts up and shuts down (tt(Startup/Shutdown Files)) or by the use of
+the `tt(source)' and `tt(dot)' builtin commands.
+)
 pindex(TYPESET_SILENT)
 pindex(NO_TYPESET_SILENT)
 pindex(TYPESETSILENT)
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.108
diff -u -r1.108 init.c
--- Src/init.c	16 Dec 2009 18:39:07 -0000	1.108
+++ Src/init.c	24 Jan 2010 21:10:31 -0000
@@ -1126,6 +1126,11 @@
     scriptname = s;
     scriptfilename = s;
 
+    if (isset(SOURCETRACE)) {
+	printprompt4();
+	fprintf(xtrerr ? xtrerr : stderr, "<sourcetrace>\n");
+    }
+
     /*
      * The special return behaviour of traps shouldn't
      * trigger in files sourced from traps; the return
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.52
diff -u -r1.52 options.c
--- Src/options.c	13 Jan 2010 12:05:49 -0000	1.52
+++ Src/options.c	24 Jan 2010 21:10:31 -0000
@@ -233,6 +233,7 @@
 {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
 {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
 {{NULL, "singlelinezle",      OPT_KSH},			 SINGLELINEZLE},
+{{NULL, "sourcetrace",        0},			 SOURCETRACE},
 {{NULL, "sunkeyboardhack",    0},			 SUNKEYBOARDHACK},
 {{NULL, "transientrprompt",   0},			 TRANSIENTRPROMPT},
 {{NULL, "trapsasync",	      0},			 TRAPSASYNC},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.161
diff -u -r1.161 zsh.h
--- Src/zsh.h	19 Jul 2009 19:08:54 -0000	1.161
+++ Src/zsh.h	24 Jan 2010 21:10:32 -0000
@@ -1999,6 +1999,7 @@
     SHWORDSPLIT,
     SINGLECOMMAND,
     SINGLELINEZLE,
+    SOURCETRACE,
     SUNKEYBOARDHACK,
     TRANSIENTRPROMPT,
     TRAPSASYNC,

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

* Re: PATCH: Add `sourcetrace' option
  2010-01-24 21:12                     ` Peter Stephenson
@ 2010-01-24 22:27                       ` Frank Terbeck
  0 siblings, 0 replies; 20+ messages in thread
From: Frank Terbeck @ 2010-01-24 22:27 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers, zsh, schaefer, richih.mailinglist

Peter Stephenson writes:
> Frank Terbeck <ft@bewatermyfriend.org> wrote:
>> Here's an updated patch. Thanks to everyone who reviewed the previous
>> attempts.
>
> I'm just toying with this variant...  the difference is this moves the
> output down until after the script name etc. is set up, and uses PS4
> (like the xtrace option), so the output is more configurable.  For
> example, I get:
>
> +/etc/zshenv:1> <sourcetrace>
> +/home/pws/.zshenv:1> <sourcetrace>
> +/home/pws/.profile:1> <sourcetrace>
> +/home/pws/.zshrc:1> <sourcetrace>
> /home/pws/.aliasrc:1:> <sourcetrace>
> /home/pws/.compinstall:1:> <sourcetrace>
> /home/pws/.zcompdump_4.3.10-dev-1_pws:1:> <sourcetrace>
>
> (the change in the middle is because I tweak PS4 to remove the "+" in
> .zshrc, for no good reason I can now think of, as well as adding %_, and
> there's only one global file because .zshenv sets NO_GLOBAL_RCS.)
>
> I'm not particularly set on this but it seems more powerful without
> losing anything obvious.  The documentation would need tweaking.

Certainly preferable. Would the documentation really need updating? The
entry for `XTRACE' doesn't mention $PS4 either. And the overall
behaviour doesn't differ from my initial approach, does it?

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


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

* Re: what is the effect of a percentage sign (%) as last character on the command line
  2010-01-24 10:58                 ` Frank Terbeck
  2010-01-24 14:50                   ` Peter
@ 2010-01-26  7:52                   ` Peter
  1 sibling, 0 replies; 20+ messages in thread
From: Peter @ 2010-01-26  7:52 UTC (permalink / raw)
  To: zsh-workers; +Cc: ft


> If `vcs_info' is included in your zsh version, this should get you to
> its documentation:
>      % MANPAGER='less -M -p GATHER' man zshcontrib
>
> Regards, Frank
>
Thanks, Frank , for the hint. In fact, I tried to use vcs_info when I 
started to configure my zsh but I just couldn't make it behave exactly 
as I wanted and finally I found it easier to write a small simple thing 
myself. Sometimes zsh configuration is just too much for a humble 
programmer (:-


Peter


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

end of thread, other threads:[~2010-01-26  8:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4B582F3C.2010709@mycircuit.org>
     [not found] ` <100121080540.ZM21444@torch.brasslantern.com>
     [not found]   ` <4B58AB3A.7050300@mycircuit.org>
2010-01-23 10:18     ` PATCH: Add `sourcetrace' option Frank Terbeck
2010-01-23 15:46       ` Baptiste Daroussin
2010-01-23 20:16       ` Richard Hartmann
2010-01-23 21:53         ` PATCH: " Frank Terbeck
2010-01-23 22:07           ` Benjamin R. Haskell
2010-01-23 22:23             ` Frank Terbeck
2010-01-23 23:46               ` Bart Schaefer
2010-01-24  0:10                 ` Frank Terbeck
2010-01-24  0:18                   ` Frank Terbeck
2010-01-24 21:12                     ` Peter Stephenson
2010-01-24 22:27                       ` Frank Terbeck
2010-01-23 22:14           ` PATCH: " Frank Terbeck
2010-01-23 23:44             ` Bart Schaefer
2010-01-24  0:05               ` Frank Terbeck
2010-01-24  9:21       ` Peter
     [not found]     ` <m3fx5y2le2.fsf@klanderman.net>
     [not found]       ` <87hbqdu9xs.fsf@ft.bewatermyfriend.org>
     [not found]         ` <4B5A26BA.5080307@mycircuit.org>
     [not found]           ` <87fx5x6918.fsf@ft.bewatermyfriend.org>
     [not found]             ` <4B5ABB0D.9010504@mycircuit.org>
     [not found]               ` <14989d6e1001230228k22e32200s10db146bd8596dc2@mail.gmail.com>
2010-01-23 12:03                 ` what is the effect of a percentage sign (%) as last character on the command line Peter
     [not found]     ` <2d3b879b1001211336m5b78982au96f267ea472af43d@mail.gmail.com>
     [not found]       ` <4B58D35D.1050208@mycircuit.org>
     [not found]         ` <100121182713.ZM21821@torch.brasslantern.com>
     [not found]           ` <4B597061.10701@mycircuit.org>
     [not found]             ` <100123155239.ZM27228@torch.brasslantern.com>
2010-01-24  9:51               ` Peter
2010-01-24 10:58                 ` Frank Terbeck
2010-01-24 14:50                   ` Peter
2010-01-26  7:52                   ` Peter

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