How to 'source' a shell script using bash from zsh?
I am using zsh and like it very much, but work a lot with Android source which has compilation scripts that require bash to be evaluated correctly. These scripts need to be sourced prior to compilation and define environment variables and shell functions that are used during compilation.
Zsh cannot source these files, and if I try to issue emulate bash
my shell becomes non-functionnal with plenty of these error every time I hit space (I am using oh-my-zsh, maybe that is a cause?):
url-quote-magic:24: bad pattern: ( ):/(|/localhost)/*
Is there a way for me not to switch to bash to evaluate these files, or to invoke a bash instance and import the new environments variables/functions it defined during sourcing into my zsh session? Or I am doomed to switch to bash every time I need to work on Android?
EDIT: found an answer to my own question. Sourcing a file using another shell does not seem to be possible, but in the case of Android macro files failing, this page brought a fix:
http://nilvec.com/building-cyanogen-from-source/
Basically, simply setting unsetopt nomatch
will ask zsh to stop complaining about unmatched wildcards, which is enough to bring the scripts to completion. There will still be one error remaining, about the use of the complete
bash internal command to add completion capabilities to one Android macro, but it is absolutely not critical here.
You could put your compilation commandline in a bash script, which sources the compilation scripts bevor executing the compilation command.
Something like
#!/bin/bash
. /path/to/environmentscript
. /path/to/morefunctionsscript
compile_command
Then instead of invoking compile_command
by hand, you just invoke your new bash script.