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

Re: sourcing a sh file in zsh



On 25 ÑÐÐÐÑÑ 2009 02:26:43 Bart Schaefer wrote:
> On Jan 24,  5:38pm, Peter Stephenson wrote:
> } Subject: Re: sourcing a sh file in zsh
> }
> } You need quotes for defining functions in an
> } emulation, or to creating a separate file.
>
> Yeah, that was one of my reasons for pondering making it a reserved
> word or the like.
>

If you are defining function in a *zsh* script, why not simply define it 
as *zsh* function?

While I see usage cases for sourcing file under specific emulation (and 
probably making it "sticky" for functions defined in it), I really do 
not see why would you want to define a csh function in a zsh script.

> } Hmm... I wonder if we should allow code from stdin
>
> That'd at least need another option, otherwise "emulate -E" would
> always read standard input, which would be bad if it appeared in a
> script and started evaluating whatever was written at it.
>
> } for things like:
> }
> } emulate -LRE sh <<HERE
> } function foo {
> }   ...
> } }
> } HERE
>
> You can always do
>
> emulate -LRE sh $(<<-\HERE
> 	function foo {
> 	 ...
> 	}
> 	HERE)
>

Actually you can always do

foo=$(<<-\HERE
 	function foo {
 	 ...
 	}
 	HERE)
emulate -c sh $foo


> I'm not sure offhand if you could double-quote all of that, easily
> ...
>
> } There's still the issue of retaining the emulation mode for
> functions } defined in that mode; I agree we really ought to tackle
> that to make } the new functionality properly useful. I expect Bart
> has ideas on the } next step; how far will we need to go?
>
> I refer you to workers/26336 where Phil makes some comments about how
> he'd modify the wordcode to handle this.
>

Assuming this is supported by zsh internals it is trivial to add option 
to emulate to set "sticky" bit during code evaluation.


Attachment: signature.asc
Description: This is a digitally signed message part.



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