0

I want to pass function arguments to zsh’s emulate to evaluate a command in bash emulation:

$ .bash() { emulate bash -c "$*" }
$ .bash 'source /path/to/script.sh'

It’s ok but I want this without quotes like a precommand modifier (to use syntax highlighting, completion, etc.) as in

$ .bash source /path/to/script.sh

The problem arises when a command line contains quoted spaces:

$ .bash source /path/to/"script with spaces".sh
$ # I want it to expand to
$ emulate bash -c 'source /path/to/"script with spaces".sh'
$ # or the like

I tried to play with different quotes and with ${(qq)*} expansion flags. No good so far.

Is there any way to achieve this?

1 Answer 1

0

You might have some success with

.bash() { emulate bash -c "$(echo ${(qq)@})" } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.