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

Re: sourcing a sh file in zsh



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.

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

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.

} [...] we could set a global flag while the "emulate" eval is being
} run that the mode flag for a function needs to be inherited from the
} emulation. Would this need another flag to "emulate", or would it be
} good enough always to inherit the emulation mode when "emulate -E" is
} in effect?

I think the latter.

} I don't think functions should *always* inherit the emulation because
} it changes the current behaviour too much---we would be resetting a
} whole load of options before every function call.

I agree.

} I would guess we don't want to apply it to autoloaded functions which
} already have their own rules.

Also agreed, which would imply:

} We do need to be quite clear on the rules to avoid tying ourselves in
} knots with things like "emaulate -LRE sh autoload foo".  "foo", in my
} interpretation, would not inherit sh behaviour here.



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