zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: Prompt fun
@ 1999-10-07  0:28 Bart Schaefer
  1999-10-07 10:41 ` PATCH: emulate (Re: Prompt fun) Zefram
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-07  0:28 UTC (permalink / raw)
  To: zsh-workers

Some of us still don't have extendedglob set all the time, you know.

Index: Functions/Prompts/promptinit
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Functions/Prompts/promptinit,v
retrieving revision 1.1
diff -u -r1.1 promptinit
--- promptinit	1999/10/06 23:40:28	1.1
+++ promptinit	1999/10/07 00:00:54
@@ -8,6 +8,7 @@
 
 promptinit () {
   emulate -L zsh
+  setopt extendedglob
   local ppath='' name
 
   # Autoload all prompt_*_setup functions in fpath


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

* PATCH: emulate (Re: Prompt fun)
  1999-10-07  0:28 PATCH: Re: Prompt fun Bart Schaefer
@ 1999-10-07 10:41 ` Zefram
  1999-10-07 14:53   ` Bart Schaefer
  1999-10-10 23:03   ` PATCH: Re: PATCH: emulate (Re: Prompt fun) Bart Schaefer
  0 siblings, 2 replies; 17+ messages in thread
From: Zefram @ 1999-10-07 10:41 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>   emulate -L zsh
>+  setopt extendedglob

This shouldn't be causing confusion.  emulate is supposed to set all
(and only) the options that can affect the behaviour of a script.
The patch below fixes this.

The patch quoted above is still necessary; EXTENDED_GLOB is unset
by default even in zsh mode.  Would changing that break any scripts?
I suspect that it wouldn't, and would be a good idea.

-zefram

--- Src/options.c~	Thu Oct  7 11:11:26 1999
+++ Src/options.c	Thu Oct  7 11:35:11 1999
@@ -69,11 +69,11 @@
  * to avoid formatting problems.
  */
 static struct optname optns[] = {
-{NULL, "allexport",	      0,			 ALLEXPORT},
+{NULL, "allexport",	      OPT_EMULATE,		 ALLEXPORT},
 {NULL, "alwayslastprompt",    OPT_ALL,			 ALWAYSLASTPROMPT},
 {NULL, "alwaystoend",	      0,			 ALWAYSTOEND},
 {NULL, "appendhistory",	      OPT_ALL,			 APPENDHISTORY},
-{NULL, "autocd",	      0,			 AUTOCD},
+{NULL, "autocd",	      OPT_EMULATE,		 AUTOCD},
 {NULL, "autolist",	      OPT_ALL,			 AUTOLIST},
 {NULL, "automenu",	      OPT_ALL,			 AUTOMENU},
 {NULL, "autonamedirs",	      0,			 AUTONAMEDIRS},
@@ -83,17 +83,17 @@
 {NULL, "autoremoveslash",     OPT_ALL,			 AUTOREMOVESLASH},
 {NULL, "autoresume",	      0,			 AUTORESUME},
 {NULL, "badpattern",	      OPT_EMULATE|OPT_NONBOURNE, BADPATTERN},
-{NULL, "banghist",	      OPT_EMULATE|OPT_NONBOURNE, BANGHIST},
+{NULL, "banghist",	      OPT_NONBOURNE,		 BANGHIST},
 {NULL, "bareglobqual",        OPT_EMULATE|OPT_ZSH,       BAREGLOBQUAL},
 {NULL, "bashautolist",	      0,                         BASHAUTOLIST},
 {NULL, "beep",		      OPT_ALL,			 BEEP},
 {NULL, "bgnice",	      OPT_EMULATE|OPT_NONBOURNE, BGNICE},
-{NULL, "braceccl",	      0,			 BRACECCL},
+{NULL, "braceccl",	      OPT_EMULATE,		 BRACECCL},
 {NULL, "bsdecho",	      OPT_EMULATE|OPT_SH,	 BSDECHO},
-{NULL, "cdablevars",	      0,			 CDABLEVARS},
-{NULL, "chasedots",	      0,			 CHASEDOTS},
-{NULL, "chaselinks",	      0,			 CHASELINKS},
-{NULL, "clobber",	      OPT_ALL,			 CLOBBER},
+{NULL, "cdablevars",	      OPT_EMULATE,		 CDABLEVARS},
+{NULL, "chasedots",	      OPT_EMULATE,		 CHASEDOTS},
+{NULL, "chaselinks",	      OPT_EMULATE,		 CHASELINKS},
+{NULL, "clobber",	      OPT_EMULATE|OPT_ALL,	 CLOBBER},
 {NULL, "completealiases",     0,			 COMPLETEALIASES},
 {NULL, "completeinword",      0,			 COMPLETEINWORD},
 {NULL, "correct",	      0,			 CORRECT},
@@ -103,17 +103,17 @@
 {NULL, "cshjunkiequotes",     OPT_EMULATE|OPT_CSH,	 CSHJUNKIEQUOTES},
 {NULL, "cshnullglob",	      OPT_EMULATE|OPT_CSH,	 CSHNULLGLOB},
 {NULL, "equals",	      OPT_EMULATE|OPT_ZSH,	 EQUALS},
-{NULL, "errexit",	      0,			 ERREXIT},
-{NULL, "exec",		      OPT_ALL,			 EXECOPT},
-{NULL, "extendedglob",	      0,			 EXTENDEDGLOB},
-{NULL, "extendedhistory",     OPT_EMULATE|OPT_CSH,	 EXTENDEDHISTORY},
+{NULL, "errexit",	      OPT_EMULATE,		 ERREXIT},
+{NULL, "exec",		      OPT_EMULATE|OPT_ALL,		 EXECOPT},
+{NULL, "extendedglob",	      OPT_EMULATE,		 EXTENDEDGLOB},
+{NULL, "extendedhistory",     OPT_CSH,			 EXTENDEDHISTORY},
 {NULL, "flowcontrol",	      OPT_ALL,			 FLOWCONTROL},
 {NULL, "functionargzero",     OPT_EMULATE|OPT_NONBOURNE, FUNCTIONARGZERO},
-{NULL, "glob",		      OPT_ALL,			 GLOBOPT},
+{NULL, "glob",		      OPT_EMULATE|OPT_ALL,	 GLOBOPT},
 {NULL, "globalrcs",           OPT_ALL,			 GLOBALRCS},
 {NULL, "globassign",	      OPT_EMULATE|OPT_CSH,	 GLOBASSIGN},
 {NULL, "globcomplete",	      0,			 GLOBCOMPLETE},
-{NULL, "globdots",	      0,			 GLOBDOTS},
+{NULL, "globdots",	      OPT_EMULATE,		 GLOBDOTS},
 {NULL, "globsubst",	      OPT_EMULATE|OPT_NONZSH,	 GLOBSUBST},
 {NULL, "hashcmds",	      OPT_ALL,			 HASHCMDS},
 {NULL, "hashdirs",	      OPT_ALL,			 HASHDIRS},
@@ -135,7 +135,7 @@
 {NULL, "ignoreeof",	      0,			 IGNOREEOF},
 {NULL, "incappendhistory",    0,			 INCAPPENDHISTORY},
 {NULL, "interactive",	      OPT_SPECIAL,		 INTERACTIVE},
-{NULL, "interactivecomments", OPT_EMULATE|OPT_BOURNE,	 INTERACTIVECOMMENTS},
+{NULL, "interactivecomments", OPT_BOURNE,		 INTERACTIVECOMMENTS},
 {NULL, "ksharrays",	      OPT_EMULATE|OPT_BOURNE,	 KSHARRAYS},
 {NULL, "kshautoload",	      OPT_EMULATE|OPT_BOURNE,	 KSHAUTOLOAD},
 {NULL, "kshglob",             OPT_EMULATE|OPT_KSH,       KSHGLOB},
@@ -149,7 +149,7 @@
 {NULL, "localtraps",	      OPT_EMULATE|OPT_KSH,	 LOCALTRAPS},
 {NULL, "login",		      OPT_SPECIAL,		 LOGINSHELL},
 {NULL, "longlistjobs",	      0,			 LONGLISTJOBS},
-{NULL, "magicequalsubst",     0,			 MAGICEQUALSUBST},
+{NULL, "magicequalsubst",     OPT_EMULATE,		 MAGICEQUALSUBST},
 {NULL, "mailwarning",	      0,			 MAILWARNING},
 {NULL, "markdirs",	      0,			 MARKDIRS},
 {NULL, "menucomplete",	      0,			 MENUCOMPLETE},
@@ -158,23 +158,23 @@
 {NULL, "nomatch",	      OPT_EMULATE|OPT_NONBOURNE, NOMATCH},
 {NULL, "notify",	      OPT_ZSH,			 NOTIFY},
 {NULL, "nullglob",	      OPT_EMULATE,		 NULLGLOB},
-{NULL, "numericglobsort",     0,			 NUMERICGLOBSORT},
+{NULL, "numericglobsort",     OPT_EMULATE,		 NUMERICGLOBSORT},
 {NULL, "overstrike",	      0,			 OVERSTRIKE},
-{NULL, "pathdirs",	      0,			 PATHDIRS},
+{NULL, "pathdirs",	      OPT_EMULATE,		 PATHDIRS},
 {NULL, "posixbuiltins",	      OPT_EMULATE|OPT_BOURNE,	 POSIXBUILTINS},
 {NULL, "printeightbit",       0,                         PRINTEIGHTBIT},
 {NULL, "printexitvalue",      0,			 PRINTEXITVALUE},
 {NULL, "privileged",	      OPT_SPECIAL,		 PRIVILEGED},
-{NULL, "promptbang",	      OPT_EMULATE|OPT_KSH,	 PROMPTBANG},
+{NULL, "promptbang",	      OPT_KSH,			 PROMPTBANG},
 {NULL, "promptcr",	      OPT_ALL,			 PROMPTCR},
-{NULL, "promptpercent",	      OPT_EMULATE|OPT_NONBOURNE, PROMPTPERCENT},
-{NULL, "promptsubst",	      OPT_EMULATE|OPT_KSH,	 PROMPTSUBST},
-{NULL, "pushdignoredups",     0,			 PUSHDIGNOREDUPS},
-{NULL, "pushdminus",	      0,			 PUSHDMINUS},
+{NULL, "promptpercent",	      OPT_NONBOURNE,		 PROMPTPERCENT},
+{NULL, "promptsubst",	      OPT_KSH,			 PROMPTSUBST},
+{NULL, "pushdignoredups",     OPT_EMULATE,		 PUSHDIGNOREDUPS},
+{NULL, "pushdminus",	      OPT_EMULATE,		 PUSHDMINUS},
 {NULL, "pushdsilent",	      0,			 PUSHDSILENT},
-{NULL, "pushdtohome",	      0,			 PUSHDTOHOME},
-{NULL, "rcexpandparam",	      0,			 RCEXPANDPARAM},
-{NULL, "rcquotes",	      0,			 RCQUOTES},
+{NULL, "pushdtohome",	      OPT_EMULATE,		 PUSHDTOHOME},
+{NULL, "rcexpandparam",	      OPT_EMULATE,		 RCEXPANDPARAM},
+{NULL, "rcquotes",	      OPT_EMULATE,		 RCQUOTES},
 {NULL, "rcs",		      OPT_ALL,			 RCS},
 {NULL, "recexact",	      0,			 RECEXACT},
 {NULL, "restricted",	      OPT_SPECIAL,		 RESTRICTED},
@@ -185,7 +185,7 @@
 {NULL, "shglob",	      OPT_EMULATE|OPT_BOURNE,	 SHGLOB},
 {NULL, "shinstdin",	      OPT_SPECIAL,		 SHINSTDIN},
 {NULL, "shoptionletters",     OPT_EMULATE|OPT_BOURNE,	 SHOPTIONLETTERS},
-{NULL, "shortloops",	      OPT_ALL,			 SHORTLOOPS},
+{NULL, "shortloops",	      OPT_EMULATE|OPT_ALL,	 SHORTLOOPS},
 {NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE,	 SHWORDSPLIT},
 {NULL, "singlecommand",	      OPT_SPECIAL,		 SINGLECOMMAND},
 {NULL, "singlelinezle",	      OPT_KSH,			 SINGLELINEZLE},
END


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 10:41 ` PATCH: emulate (Re: Prompt fun) Zefram
@ 1999-10-07 14:53   ` Bart Schaefer
  1999-10-07 15:11     ` Zefram
  1999-10-10 23:03   ` PATCH: Re: PATCH: emulate (Re: Prompt fun) Bart Schaefer
  1 sibling, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-07 14:53 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-workers

On Oct 7, 11:41am, Zefram wrote:
} Subject: PATCH: emulate (Re: Prompt fun)
}
} Bart Schaefer wrote:
} >   emulate -L zsh
} >+  setopt extendedglob
} 
} This shouldn't be causing confusion.  emulate is supposed to set all
} (and only) the options that can affect the behaviour of a script.
} The patch below fixes this.

I disagree with a number of these changes, particularly promptbang,
promptpercent, and promptsubst.  Most scripts do not alter the values
of PS[1234], and resetting the prompt-expansion options will cause the
user's settings to display as garbage in conjunction with either use
of "select" loops or (as of 3.1.6) "setopt xtrace"/"set -x".

I further think it's unwise to have emulate reset either errexit or
"exec" -- though I don't see how it could possibly make any difference
to the latter, as emulate itself won't be executed if exec isn't set.

I don't have any really strong feelings about the others, though there
may be room for some debate as to how many of them are "likely to cause
portability problems in scripts and functions."  Certainly I agree with
some of the changes, e.g. the history options ought *not* to be reset.

} The patch quoted above is still necessary; EXTENDED_GLOB is unset
} by default even in zsh mode.  Would changing that break any scripts?

Yes, it would break some of my scripts.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 14:53   ` Bart Schaefer
@ 1999-10-07 15:11     ` Zefram
  1999-10-07 15:42       ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Zefram @ 1999-10-07 15:11 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zefram, zsh-workers

Bart Schaefer wrote:
>I disagree with a number of these changes, particularly promptbang,
>promptpercent, and promptsubst.  Most scripts do not alter the values
>of PS[1234], and resetting the prompt-expansion options will cause the
>user's settings to display as garbage in conjunction with either use
>of "select" loops or (as of 3.1.6) "setopt xtrace"/"set -x".

I changed them to *not* be set by emulate.  They're a user interaction
matter, and really can't directly affect the operation of scripts,
so should not be set by emulate.

>I further think it's unwise to have emulate reset either errexit or
>"exec" -- though I don't see how it could possibly make any difference
>to the latter, as emulate itself won't be executed if exec isn't set.

I was a bit dubious about these, and a few others with that type of
meta effect, such as XTRACE.  On reflection, I think the criterion that
needs to be used is "is it valid to change this option within a script,
as a programming technique?".  "emulate -L zsh" is really the idiom used
to get known standard behaviour in a zsh function, so everything that
affects the direct behaviour of the function should be set by it.

With ERR_EXIT, I was imagining that a user might set the option in a
script (it can be quite convenient in scripts run from make), and then
call a function that doesn't want ERR_EXIT set -- the function should
decide for itself how to handle errors.  Applying the criterion I state
above, it is normal to set this option within a script -- it has the
effect of suffixing all commands with "|| exit", which is sometimes what
one wants.

For EXEC, really there's no reason to change it within a script.  Its sole
purpose is for syntax checking of a script, so I agree that it shouldn't
be considered to be emulation-relevant.

>                                                 Certainly I agree with
>some of the changes, e.g. the history options ought *not* to be reset.

Right.  Again, these are user interaction features, and don't affect
scripts.
>
>} The patch quoted above is still necessary; EXTENDED_GLOB is unset
>} by default even in zsh mode.  Would changing that break any scripts?
>
>Yes, it would break some of my scripts.

A pity.

-zefram


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 15:11     ` Zefram
@ 1999-10-07 15:42       ` Bart Schaefer
  1999-10-07 15:50         ` Zefram
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-07 15:42 UTC (permalink / raw)
  To: zsh-workers

On Oct 7,  4:11pm, Zefram wrote:
} Subject: Re: PATCH: emulate (Re: Prompt fun)
}
} Bart Schaefer wrote:
} >resetting the prompt-expansion options will cause the
} >user's settings to display as garbage
} 
} I changed them to *not* be set by emulate.

Ah, sorry, I read that hunk backwards.

} With ERR_EXIT, I was imagining that a user might set the option in a
} script (it can be quite convenient in scripts run from make), and then
} call a function that doesn't want ERR_EXIT set -- the function should
} decide for itself how to handle errors.

Hmm.  I tend to think of it exactly the opposite way -- if I set errexit,
I generally want it to continue to apply down through functions I call,
because of exactly the circumstances you note -- scripts run from make,
which uses -e when it invokes the shell.

} >} The patch quoted above is still necessary; EXTENDED_GLOB is unset
} >} by default even in zsh mode.  Would changing that break any scripts?
} >
} >Yes, it would break some of my scripts.
} 
} A pity.

If emacs vc didn't have a tendency to create files with names that look
like basename~version~ it'd be less of a problem, because I already
habitually quote carats (some old Bourne shells read carat as pipe, from
the days when many keyboards lacked a vertical bar).

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 15:42       ` Bart Schaefer
@ 1999-10-07 15:50         ` Zefram
  1999-10-07 17:20           ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Zefram @ 1999-10-07 15:50 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>Hmm.  I tend to think of it exactly the opposite way -- if I set errexit,
>I generally want it to continue to apply down through functions I call,
>because of exactly the circumstances you note -- scripts run from make,
>which uses -e when it invokes the shell.

Hmm.  Surely in that case, the functions in question are going to be ones
written to be executed in the context of that particular script, and
will be intended to have ERR_EXIT set, and won't have an emulate line?
emulate will be used in functions intended to be used in many places,
and these functions should indicate errors by themselves returning with
a non-zero status, which will come under the purview of the caller's
ERR_EXIT setting.  I've often written code like

	# I don't care if foo doesn't exist, so ignore the return code
	mv -f foo bar

which, if it were in a generic function, shoud have "emulate -L zsh",
and would be broken by ERR_EXIT being set unexpectedly.

-zefram


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 15:50         ` Zefram
@ 1999-10-07 17:20           ` Bart Schaefer
  1999-10-07 17:29             ` Zefram
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-07 17:20 UTC (permalink / raw)
  To: zsh-workers

On Oct 7,  4:50pm, Zefram wrote:
} Subject: Re: PATCH: emulate (Re: Prompt fun)
}
} Bart Schaefer wrote:
} >Hmm.  I tend to think of it exactly the opposite way -- if I set errexit,
} >I generally want it to continue to apply down through functions I call,
} >because of exactly the circumstances you note -- scripts run from make,
} >which uses -e when it invokes the shell.
} 
} Hmm.  Surely in that case, the functions in question are going to be ones
} written to be executed in the context of that particular script, and
} will be intended to have ERR_EXIT set, and won't have an emulate line?

The function might be written so that zsh executes it as an autoload but
bash runs it as a separate script process.  In the former case, an emulate
might be required.

However, I admit that there is merit in your argument; it's just that I
tend to want to resolve conflicts by *not* changing existing behavior ...

Which reminds me:  I believe the original intent of "emulate" was not to
reset _all_ options that might affect parsing (unless "emulate -R" is
used).  I believe the intent was to reset any option that would confuse
a ksh or sh script running in zsh.  Options like "cdablevars" and "autocd"
were *not* handled by "emulate" because no reasonable ksh script could
possibly depend upon those behaviors, nor could a correctly-working ksh
script use syntax that could accidentally trigger them.

Scripts that need to port among different users' zsh configurations, as
opposed to porting zsh<->ksh, were supposed to use "emulate -R" and then
setopt exactly the options they needed.

Perhaps the situation has changed enough, now that large parts of the zsh
distribution are written as zsh scripts, that we should revisit that and
make most of the changes in Zefram's patch.  On the other hand, I'm as
usual loathe to make "silent" changes to the option semantics.  I'd much
rather see an additional flag to "emulate" that catches these additional
problem cases.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 17:20           ` Bart Schaefer
@ 1999-10-07 17:29             ` Zefram
  1999-10-07 18:56               ` Bart Schaefer
  1999-10-07 20:32               ` Reasons for not wanting EXTENDED_GLOB interactively (was Re: PATCH:...) Bruce Stephens
  0 siblings, 2 replies; 17+ messages in thread
From: Zefram @ 1999-10-07 17:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>Which reminds me:  I believe the original intent of "emulate" was not to
>reset _all_ options that might affect parsing (unless "emulate -R" is
>used).  I believe the intent was to reset any option that would confuse
>a ksh or sh script running in zsh.  Options like "cdablevars" and "autocd"
>were *not* handled by "emulate" because no reasonable ksh script could
>possibly depend upon those behaviors, nor could a correctly-working ksh
>script use syntax that could accidentally trigger them.

Those two will rarely make any difference.  I can imagine, though,
scripts that tentatively attempt to execute a command, and may well have
unexpected behaviour if they start cd'ing around as a result.

emulate -R is there to change the shell completely to the specified
emulation, as if it had been started under that name.  It's useful
primarily in interactive shells.  emulate without -R is supposed to
emulate (hence the name) the specified shell, as much as necessary for
scripts to be able to run unchanged (subject to the limited capabilities
of zsh to emulate other shells).  To do this, emulate without -R really
needs to set all options that affect script behaviour.

>                                             On the other hand, I'm as
>usual loathe to make "silent" changes to the option semantics.  I'd much
>rather see an additional flag to "emulate" that catches these additional
>problem cases.

So when would we use this additional flag?  It would have to be used
essentially all the time, with plain emulate left just for backward
compatibility.  I find it difficult to believe that anything actually
relies on "emulate zsh" *not* resetting EXTENDED_GLOB.

-zefram


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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 17:29             ` Zefram
@ 1999-10-07 18:56               ` Bart Schaefer
  1999-10-08  9:58                 ` Zefram
  1999-10-07 20:32               ` Reasons for not wanting EXTENDED_GLOB interactively (was Re: PATCH:...) Bruce Stephens
  1 sibling, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-07 18:56 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-workers

On Oct 7,  6:29pm, Zefram wrote:
> Subject: Re: PATCH: emulate (Re: Prompt fun)
> emulate without -R is supposed to
> emulate (hence the name) the specified shell, as much as necessary for
> scripts to be able to run unchanged

Yes; the question is, when "the specified shell" is zsh, what does it mean
to emulate it?  After all, zsh is already zsh ... by definition, any option
not specifically intended for emulation of some other shell is already
being emulated "as if zsh," no matter what its setting.

However, this is mostly thinking about things from an interactive-shell
viewpoint, not from a function/script viewpoint.  So how about this:

> >[I'm] loathe to make "silent" changes to the option semantics.  I'd much
> >rather see an additional flag to "emulate" that catches these additional
> >problem cases.
> 
> So when would we use this additional flag?  It would have to be used
> essentially all the time, with plain emulate left just for backward
> compatibility.

We already have to use the -L option essentially all the time, and it makes
little sense to use -L in an interactive context.  Why not overload -L with
this semantics, and leave plain "emulate" as it was?


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

* Reasons for not wanting EXTENDED_GLOB interactively (was Re: PATCH:...)
  1999-10-07 17:29             ` Zefram
  1999-10-07 18:56               ` Bart Schaefer
@ 1999-10-07 20:32               ` Bruce Stephens
  1999-10-08  6:15                 ` Andrej Borsenkow
  1 sibling, 1 reply; 17+ messages in thread
From: Bruce Stephens @ 1999-10-07 20:32 UTC (permalink / raw)
  To: zsh-workers

Zefram <zefram@fysh.org> writes:

> I find it difficult to believe that anything actually relies on
> "emulate zsh" *not* resetting EXTENDED_GLOB.

This isn't really on the same subject, but a colleague wanted to
delete files beginning .# in a directory a few days ago (they're
created by Emacs ediffing files with versions or something), and did:

        rm .#*

(Don't try this at home.)

I'm not sure whether this is a bug in zsh.  After all, the "rm *"
warning is a special case (and useful, too, IMHO).

Hmm, how about changing the implementation of the check?  Presumably
the current test looks for * explicitly; an alternative (slightly more
expensive) would be to do the expansion and see if it includes all of
the files or not, and if it does, issue the warning.  

In fact, one could probably do this as a shell function, instead.
That probably makes more sense.


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

* RE: Reasons for not wanting EXTENDED_GLOB interactively (was Re: PATCH:...)
  1999-10-07 20:32               ` Reasons for not wanting EXTENDED_GLOB interactively (was Re: PATCH:...) Bruce Stephens
@ 1999-10-08  6:15                 ` Andrej Borsenkow
  0 siblings, 0 replies; 17+ messages in thread
From: Andrej Borsenkow @ 1999-10-08  6:15 UTC (permalink / raw)
  To: Bruce Stephens, zsh-workers

>
> This isn't really on the same subject, but a colleague wanted to
> delete files beginning .# in a directory a few days ago (they're
> created by Emacs ediffing files with versions or something), and did:
>
>         rm .#*
>
> (Don't try this at home.)
>

Wow! I often use some patterns with exclusion and like so I have extended_glob
on ... Peter, how hard is to implement globbing modifier to turn extended_glob
on (and, may be, off)? Something like (#e)... ??

/andrej



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

* Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 18:56               ` Bart Schaefer
@ 1999-10-08  9:58                 ` Zefram
  0 siblings, 0 replies; 17+ messages in thread
From: Zefram @ 1999-10-08  9:58 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zefram, zsh-workers

Bart Schaefer wrote:
>We already have to use the -L option essentially all the time, and it makes
>little sense to use -L in an interactive context.  Why not overload -L with
>this semantics, and leave plain "emulate" as it was?

Ugh.  Overloading options like this is just confusing.  "emulate" and
"emulate -L" should behave exactly the same, except with respect to
LOCAL_{OPTIONS,TRAPS}.

-zefram


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

* PATCH: Re: PATCH: emulate (Re: Prompt fun)
  1999-10-07 10:41 ` PATCH: emulate (Re: Prompt fun) Zefram
  1999-10-07 14:53   ` Bart Schaefer
@ 1999-10-10 23:03   ` Bart Schaefer
  1999-10-10 23:19     ` Bart Schaefer
  1999-10-10 23:21     ` Bart Schaefer
  1 sibling, 2 replies; 17+ messages in thread
From: Bart Schaefer @ 1999-10-10 23:03 UTC (permalink / raw)
  To: zsh-workers

As per the discussion that followed Zefram's changes in 8152 and 8154, this
backs out manipulation of `exec' by emulate, and makes `extendeglob' be off
by default again.  I'm persuaded that the rest of the changes were OK.

Index: Doc/Zsh/options.yo
===================================================================
@@ -329,7 +329,7 @@
 )
 pindex(EXTENDED_GLOB)
 cindex(globbing, extended)
-item(tt(EXTENDED_GLOB) <Z>)(
+item(tt(EXTENDED_GLOB))(
 Treat the `tt(#)', `tt(~)' and `tt(^)' characters as part of patterns
 for filename generation, etc.  (An initial unquoted `tt(~)'
 always produces named directory expansion.)
Index: Src/options.c
===================================================================
@@ -104,8 +104,8 @@
 {NULL, "cshnullglob",	      OPT_EMULATE|OPT_CSH,	 CSHNULLGLOB},
 {NULL, "equals",	      OPT_EMULATE|OPT_ZSH,	 EQUALS},
 {NULL, "errexit",	      OPT_EMULATE,		 ERREXIT},
-{NULL, "exec",		      OPT_EMULATE|OPT_ALL,		 EXECOPT},
-{NULL, "extendedglob",	      OPT_EMULATE|OPT_ZSH,	 EXTENDEDGLOB},
+{NULL, "exec",		      OPT_ALL,			 EXECOPT},
+{NULL, "extendedglob",	      OPT_EMULATE,		 EXTENDEDGLOB},
 {NULL, "extendedhistory",     OPT_CSH,			 EXTENDEDHISTORY},
 {NULL, "flowcontrol",	      OPT_ALL,			 FLOWCONTROL},
 {NULL, "functionargzero",     OPT_EMULATE|OPT_NONBOURNE, FUNCTIONARGZERO},


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: Re: PATCH: emulate (Re: Prompt fun)
  1999-10-10 23:03   ` PATCH: Re: PATCH: emulate (Re: Prompt fun) Bart Schaefer
@ 1999-10-10 23:19     ` Bart Schaefer
  1999-10-11  8:20       ` Zefram
  1999-10-10 23:21     ` Bart Schaefer
  1 sibling, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-10 23:19 UTC (permalink / raw)
  To: zsh-workers

On Oct 10, 11:03pm, Bart Schaefer wrote:
} Subject: PATCH: Re: PATCH: emulate (Re: Prompt fun)
}
} I'm persuaded that the rest of the changes were OK.

I was just going through making these same changes in 3.0.6, when I was
brought to a sudden halt by `promptsubst'.  It occurs to me that printing
the prompt can actually cause commands to be executed when `promptsubst'
is set, because of $(...) substitutions.  Depending on what those commands
do, that certainly could affect the behavior of a script.  I suppose it's
not a major issue, but I wanted to ask whether anyone else has an opinion
about it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: Re: PATCH: emulate (Re: Prompt fun)
  1999-10-10 23:03   ` PATCH: Re: PATCH: emulate (Re: Prompt fun) Bart Schaefer
  1999-10-10 23:19     ` Bart Schaefer
@ 1999-10-10 23:21     ` Bart Schaefer
  1999-10-11  8:17       ` Zefram
  1 sibling, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-10-10 23:21 UTC (permalink / raw)
  To: zsh-workers

On Oct 10, 11:03pm, Bart Schaefer wrote:
} Subject: PATCH: Re: PATCH: emulate (Re: Prompt fun)
}
} I'm persuaded that the rest of the changes were OK.

One last question:  Should `shortloops' be OPT_CSH as well as OPT_ZSH ?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: Re: PATCH: emulate (Re: Prompt fun)
  1999-10-10 23:21     ` Bart Schaefer
@ 1999-10-11  8:17       ` Zefram
  0 siblings, 0 replies; 17+ messages in thread
From: Zefram @ 1999-10-11  8:17 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>One last question:  Should `shortloops' be OPT_CSH as well as OPT_ZSH ?

It is, after the patch I sent for it.  That's what OPT_NONBOURNE means.
Or did you miss that patch because it was sent in the same message as
the EXTENDED_GLOB patch?

-zefram


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

* Re: PATCH: Re: PATCH: emulate (Re: Prompt fun)
  1999-10-10 23:19     ` Bart Schaefer
@ 1999-10-11  8:20       ` Zefram
  0 siblings, 0 replies; 17+ messages in thread
From: Zefram @ 1999-10-11  8:20 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>                                            It occurs to me that printing
>the prompt can actually cause commands to be executed when `promptsubst'
>is set, because of $(...) substitutions.  Depending on what those commands
>do, that certainly could affect the behavior of a script.

It's up to the user.  The user sets the prompt, and if the user wants
to execute commands when printing the prompt then so be it.  Of course,
executing commands that have side effects would be a bad idea.

-zefram


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

end of thread, other threads:[~1999-10-11  8:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-07  0:28 PATCH: Re: Prompt fun Bart Schaefer
1999-10-07 10:41 ` PATCH: emulate (Re: Prompt fun) Zefram
1999-10-07 14:53   ` Bart Schaefer
1999-10-07 15:11     ` Zefram
1999-10-07 15:42       ` Bart Schaefer
1999-10-07 15:50         ` Zefram
1999-10-07 17:20           ` Bart Schaefer
1999-10-07 17:29             ` Zefram
1999-10-07 18:56               ` Bart Schaefer
1999-10-08  9:58                 ` Zefram
1999-10-07 20:32               ` Reasons for not wanting EXTENDED_GLOB interactively (was Re: PATCH:...) Bruce Stephens
1999-10-08  6:15                 ` Andrej Borsenkow
1999-10-10 23:03   ` PATCH: Re: PATCH: emulate (Re: Prompt fun) Bart Schaefer
1999-10-10 23:19     ` Bart Schaefer
1999-10-11  8:20       ` Zefram
1999-10-10 23:21     ` Bart Schaefer
1999-10-11  8:17       ` Zefram

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