Skip to main content
deleted 63 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237

(Not sure the title is adequate, at least I tried my best…)

 

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?

(Not sure the title is adequate, at least I tried my best…)

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?

 

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?

Source Link

Expand parameter in quotes in zsh

(Not sure the title is adequate, at least I tried my best…)

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?