zsh-workers
 help / color / mirror / code / Atom feed
* setopt temporarily?
@ 2014-02-20 21:06 Dave Yost
  2014-02-20 23:33 ` Phil Pennock
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Yost @ 2014-02-20 21:06 UTC (permalink / raw)
  To: zsh-workers

One can set an environment variable only for the command that follows:

    foo=bar echo $foo 

It would be nice to be able similarly to temporarily set an option.

Perhaps setopt could terminate its arg parsing with a - or -- like this:

    setopt pushdSilent - pushd Desktop

Or maybe there needs to be a more general syntax for changing anything in zsh only for the following command.

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

* Re: setopt temporarily?
  2014-02-20 21:06 setopt temporarily? Dave Yost
@ 2014-02-20 23:33 ` Phil Pennock
  2014-02-21  2:45   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Pennock @ 2014-02-20 23:33 UTC (permalink / raw)
  To: Dave Yost; +Cc: zsh-workers

On 2014-02-20 at 13:06 -0800, Dave Yost wrote:
> It would be nice to be able similarly to temporarily set an option.
> 
> Perhaps setopt could terminate its arg parsing with a - or -- like this:
> 
>     setopt pushdSilent - pushd Desktop
> 
> Or maybe there needs to be a more general syntax for changing anything in zsh only for the following command.

Anonymous function.

(){ setopt localoptions xtrace; ls }

-Phil


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

* Re: setopt temporarily?
  2014-02-20 23:33 ` Phil Pennock
@ 2014-02-21  2:45   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2014-02-21  2:45 UTC (permalink / raw)
  To: Dave Yost, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 694 bytes --]

On Thursday, February 20, 2014, Phil Pennock <
zsh-workers+phil.pennock@spodhuis.org> wrote:

> On 2014-02-20 at 13:06 -0800, Dave Yost wrote:
> > It would be nice to be able similarly to temporarily set an option.
>
> Anonymous function.
>
> (){ setopt localoptions xtrace; ls }
>

Also the emulate command:  emulate zsh -o pushdSilent -c 'pushd Desktop'

But in most cases a function with localoptions is what you want.

Incidentally, note that the behavior of
 var=value command
depends on what the command is.  If it's an external command, the variable
is not just temporarily set, it's temporarily exported into the
environment.  For certain builtins the variable becomes permanently set.

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

end of thread, other threads:[~2014-02-21  2:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20 21:06 setopt temporarily? Dave Yost
2014-02-20 23:33 ` Phil Pennock
2014-02-21  2:45   ` 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).