zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Subject: Re: When should interactive option be set/.zshrc read?
Date: Wed, 6 Sep 2000 15:25:37 +0000	[thread overview]
Message-ID: <1000906152537.ZM22504@candle.brasslantern.com> (raw)
In-Reply-To: <000601c017ff$bedcbad0$21c9ca95@mow.siemens.ru>
In-Reply-To: <200009061249.OAA01000@beta.informatik.hu-berlin.de>
In-Reply-To: <0G0G00B57UDM35@la-la.cambridgesiliconradio.com>
In-Reply-To: <000701c01803$20bcb360$21c9ca95@mow.siemens.ru>
In-Reply-To: =?iso-8859-1?Q?=3C20000906151242=2EA7778=40picard=2Efranken?= =?iso-8859-1?Q?=2Ede=3E?= =?iso-8859-1?Q?Comments=3A_In_reply_to_Thomas_K=F6hler_=3Cjean-luc=40pica?= =?iso-8859-1?Q?rd=2Efranken=2Ede=3E?= =?iso-8859-1?Q?________=22Re=3A_When_should_interactive_option_be_set=2F?= =?iso-8859-1?Q?=2Ezshrc_read=3F=22_=28Sep__6=2C__3=3A12pm=29?=
In-Reply-To: <000801c01805$b10d35f0$21c9ca95@mow.siemens.ru>

On Sep 6,  2:49pm, Sven Wischnowsky wrote:
} 
} > bor@itsrm2% print $options[interactive]
} > on <= correct
} > bor@itsrm2% : | (print $options[interactive])
} > on <= ?? I doubt, this shell can be considered "interactive"
} 
} It's a copy of the interactive shell, a subshell. It doesn't read any
} init files whatsoever.
} 
} Hm, but maybe we should turn off the option in subshells. (And probably 
} other options, too?)

On Sep 6,  1:51pm, Peter Stephenson wrote:
}
} It does unset the options MONITOR and USEZLE, but not INTERACTIVE, for the
} subshell, however.   One might have thought that it would either change all
} three or none.  In particular, the effect of claiming to be interactive but
} not using ZLE looks a bit weird.

The MONITOR option is turned off because it's used internally to decide
whether you can background a job and then foreground it again.  Although
it might be sensible to do

	(job1 & job2 ; fg)

it's not sensible to do

	(job1 &) ; fg

because the background job is not a child of the shell doing the `fg'.

Possibly the test for whether bg/fg work should be separate from the
test for whether the shell reports a background job's exit status, but
it has never been that way.  Bash, for example, shows the "monitor"
option set if you do `(set -o)', but doesn't track the status of any
background jobs.

Of course, you can get the equivalent of the first example with

	(job1 & job2 ; wait)

USEZLE is a tad odd.  It means you can't do things like

	(vared foo)

I believe the reason for this is that a subshell is also used to run
background jobs and jobs in pipelines, neither of which should mess with
the terminal settings; it's likely that zsh could differentiate a
foreground ( ) from a pipeline or backgrounded command for this purpose,
but presently it does not.

On Sep 6,  5:05pm, Andrej Borsenkow wrote:
} Subject: RE: When should interactive option be set/.zshrc read?
}
} > It's a copy of the interactive shell, a subshell. It doesn't read any
} > init files whatsoever.
} 
} Um, really. Which is even worse.

What?  You've got to be kidding.

} By definition, INTERACTIVE is set "if the standard input is a tty and
} commands are being read from standard input".

That tells how the *startup time* setting of INTERACTIVE is done.  It is
not intended to mean that the option changes every time you redirect input.

} Well, I am concerned now how to prevent all definitions from .zshrc to
} be used in subshell.

If you think about this for even a few minutes, you'll realize that all
sorts of things would break if subshells behaved like "zsh -f".

zagzig[339] bash
[schaefer@zagzig]$ alias ls='echo foo'
[schaefer@zagzig]$ (ls)
foo
[schaefer@zagzig]$ function echo () { /bin/echo bar "$@" }
[schaefer@zagzig]$ (ls)
bar foo
[schaefer@zagzig]$ tcsh
[schaefer@candle]$ alias ls 'echo foo'
[schaefer@candle]$ (ls)
foo
[schaefer@candle]$ exit
[schaefer@candle]$ (sleep 30 & sleep 3; fg)
[1] 22485
No job control in subshells.
[schaefer@zagzig]$ (sleep 30 & sleep 3; fg)
fg: no job control
[schaefer@zagzig]$ exit

(Ignore the silly way that tcsh gets the hostname; "zagzig" and "candle"
are host-aliases for the same machine.)

On Sep 6,  3:12pm, Thomas Köhler wrote:
}
} Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru> wrote:
} > 
} [...]
} > I definitely do not want that (ls foo| ...) use my alias for ls; and
} > I do not want window title be mangled. Any idea? Is it possible to
} > provide "clean sandbox" for subshells?
} 
} zsh -f

More completely,

	zsh -fc 'ls foo|...'

On Sep 6,  5:23pm, Andrej Borsenkow wrote:
}
} Here is what SUS V2 says:
} 
} A subshell environment will be created as a duplicate of the shell
} environment, except that signal traps set by that shell environment
} will be set to the default values.

Yup.

Incidentally, as to your specific problem with chpwd(), why not set the
window title in precmd() instead?

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

      parent reply	other threads:[~2000-09-06 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-06 12:41 Andrej Borsenkow
2000-09-06 12:49 ` Sven Wischnowsky
2000-09-06 13:05   ` Andrej Borsenkow
2000-09-06 13:12     ` Thomas Köhler
2000-09-06 12:51 ` Peter Stephenson
2000-09-06 13:23   ` Andrej Borsenkow
2000-09-06 14:36     ` Peter Stephenson
2000-09-06 15:25     ` Bart Schaefer [this message]

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=1000906152537.ZM22504@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.auc.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).