zsh-workers
 help / color / mirror / code / Atom feed
* HOW TO distiguish between command input and forked subshell ?
@ 1996-09-05 22:47 C. v. Stuckrad
  1996-09-05 23:23 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: C. v. Stuckrad @ 1996-09-05 22:47 UTC (permalink / raw)
  To: Zsh workers list


Hi! (again :-)

I have another very spcific question...

I would like to have a zsh-function behave different if called
inside $(...) or backticks !
Exactly, I want to have the function 'chpwd' give some output
if triggered by 'cd' or 'chdir' BUT TO GIVE NO OUTPUT
if triggered by cases like  '... $(cd somewhere; ls)...' 

Might that be possible ?

Clueless (again),  Stucki

Christoph von Stuckrad       * *  | talk to  | <stucki@math.fu-berlin.de> \
Freie Universitaet Berlin    |/_* | nickname | ...!unido!fub!leibniz!stucki|
Fachbereich Mathematik, EDV  |\ * | 'stucki' | Tel:+49 30 838-7545{9|8}    |
Arnimallee 2-6/14195 Berlin  * *  |  on IRC  | Fax:+49 30 838-5913        /


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

* Re: HOW TO distiguish between command input and forked subshell ?
  1996-09-05 22:47 HOW TO distiguish between command input and forked subshell ? C. v. Stuckrad
@ 1996-09-05 23:23 ` Bart Schaefer
  1996-09-06  9:08   ` Andrej Borsenkow
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 1996-09-05 23:23 UTC (permalink / raw)
  To: C. v. Stuckrad; +Cc: Zsh workers list

On Sep 6, 12:47am, C. v. Stuckrad wrote:
> Subject: HOW TO distiguish between command input and forked subshell ?
> 
> Hi! (again :-)

You should be asking these questions on zsh-users rather than zsh-workers.
They don't have much to do with zsh development or build problems.

Not that it would matter much, since everybody on zsh-workers also gets
zsh-users, but some people might be filtering based on the To: address.

> Exactly, I want to have the function 'chpwd' give some output
> if triggered by 'cd' or 'chdir' BUT TO GIVE NO OUTPUT
> if triggered by cases like  '... $(cd somewhere; ls)...' 
> 
> Might that be possible ?

chpwd() {
    if [[ -t 1 ]]
    then
	print By golly, my standard output is a terminal.
    fi
}


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

* Re: HOW TO distiguish between command input and forked subshell ?
  1996-09-05 23:23 ` Bart Schaefer
@ 1996-09-06  9:08   ` Andrej Borsenkow
  1996-09-06 10:47     ` Zoltan Hidvegi
  0 siblings, 1 reply; 4+ messages in thread
From: Andrej Borsenkow @ 1996-09-06  9:08 UTC (permalink / raw)
  To: Zsh workers list; +Cc: Bart Schaefer

On Thu, 5 Sep 1996, Bart Schaefer wrote:

> 
> > Exactly, I want to have the function 'chpwd' give some output
> > if triggered by 'cd' or 'chdir' BUT TO GIVE NO OUTPUT
> > if triggered by cases like  '... $(cd somewhere; ls)...' 
> > 
> > Might that be possible ?
> 
> chpwd() {
>     if [[ -t 1 ]]
>     then
> 	print By golly, my standard output is a terminal.
>     fi
> }
> 

There is a little problem with output of chdir(). Here follows:

if I cd to non-local directory using CDPATH, cd will report current
directory after changing to it. I always found it boring (as I have
directory in prompt anyway) and suggested the option to shut it off. The
answer was (as expected ;) that I can use

cd () { builtin cd $* > /dev/null }

Well, it works, but any output from chdir() is also lost :( I don't
know, if it is right, that chdir() is using the same descriptor as cd, but
if it is to be so, may be new option is still useful? 

greetings

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
-------------------------------------------------------------------------



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

* Re: HOW TO distiguish between command input and forked subshell ?
  1996-09-06  9:08   ` Andrej Borsenkow
@ 1996-09-06 10:47     ` Zoltan Hidvegi
  0 siblings, 0 replies; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-09-06 10:47 UTC (permalink / raw)
  To: borsenkow.msk; +Cc: zsh-workers, bart

> if I cd to non-local directory using CDPATH, cd will report current
> directory after changing to it. I always found it boring (as I have
> directory in prompt anyway) and suggested the option to shut it off. The
> answer was (as expected ;) that I can use
> 
> cd () { builtin cd $* > /dev/null }
> 
> Well, it works, but any output from chdir() is also lost :( I don't
> know, if it is right, that chdir() is using the same descriptor as cd, but
> if it is to be so, may be new option is still useful? 

I assume that chdir above was really ment to be chpwd.  Chpwd output is not
lost if it is redirected to stderr.

Zoltan


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

end of thread, other threads:[~1996-09-06 10:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-05 22:47 HOW TO distiguish between command input and forked subshell ? C. v. Stuckrad
1996-09-05 23:23 ` Bart Schaefer
1996-09-06  9:08   ` Andrej Borsenkow
1996-09-06 10:47     ` Zoltan Hidvegi

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