Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sourcing a sh file in zsh
- X-seq: zsh-workers 26384
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: sourcing a sh file in zsh
- Date: Tue, 20 Jan 2009 20:48:50 -0800
- In-reply-to: <20090120194847.58a30c9a@pws-pc>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <BD9D2405-AD6A-4336-9C8A-85149165B6B8@xxxxxxxxx> <090116075615.ZM21871@xxxxxxxxxxxxxxxxxxxxxx> <200901161939.54651.arvidjaar@xxxxxxxxxx> <090116102934.ZM22119@xxxxxxxxxxxxxxxxxxxxxx> <20090117035923.GA64953@xxxxxxxxxxxxxxxxxxxx> <090116210045.ZM22623@xxxxxxxxxxxxxxxxxxxxxx> <20090117055559.GA60339@xxxxxxxxxxxxxxxxxxxx> <090117121501.ZM8940@xxxxxxxxxxxxxxxxxxxxxx> <20090120194847.58a30c9a@pws-pc>
On Jan 20, 7:48pm, Peter Stephenson wrote:
}
} > Combined with allowing "emulate" create a scope and run a command
} > in that scope, is there anything else you'd need?
} >
} > PWS, any comment on how difficult it would be to extend "emulate" in
} > this way? Would it require promoting emulate to a keyword?
}
} I haven't heard anything that sounds particularly difficult, although it
} obviously needs a firm grip on what's being set at what point. I don't
} see why emulate should have to behave specially as far as syntax is
} concerned, as long as its behaviour is well defined.
My thought was that emulate behave syntactically something like "exec":
% var="a string with spaces"
% emulate sh print -l $var
a
string
with
spaces
There'd also be an option to go with -L and -R to cause the emulation
mode to become "sticky" in the wordcode for any function defined "in
the scope of" the emulate ("-X" used here as placeholder):
% emulate -X sh function foo { print -l $@ }
% foo "more spaces here"
more
spaces
here
It may be going too far to make emulate a syntactic element like that.
So the next best thing is if it works more like "eval":
% emulate -X sh 'foo() { print -l $@ }'
The most frequent intended usage being
% emulate -X sh source ~/some_bash_library.sh
which would apply the "sticky emulation" to all the functions that
might be defined by some_bash_library.sh.
Maybe the sticky-option isn't even needed, maybe it should just always
become sticky when called with a command as arguments.
There are all sorts of variants of this that I'd find acceptable.
One that might be esthetically pleasing would be using a -c option,
as if you were running the shell in question:
% emulate ksh -c 'source ~/some_ksh_library.sh'
That's probably enough examples.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author