Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: When should interactive option be set/.zshrc read?



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


Messages sorted by: Reverse Date, Date, Thread, Author