zunit-zsh / zunit

A powerful testing framework for ZSH projects
https://zunit.xyz
MIT License
208 stars 23 forks source link

helpers.zsh: Change the special-constructs (like `>>') handling for eval #111

Closed psprint closed 4 years ago

psprint commented 4 years ago

Now there's no problem when the argument itself contains a double-quote, as it's automatically quoted by using the (q) flag. Before, when someone did e.g.:

var='"hello" "world"`
run cmd "$var" !

Then the command that would have been executed would be:

eval 'cmd ""hello" "world"" "!"`'

which was pretty meaningless thing to do ̧– to add the extra double-quotes around the argument. Now, the command that'll be run will be:

eval 'cmd \"hello\"\ \"world\" \!'

And it'll work as expected – the eval will receive the arguments correctly separated.

psprint commented 4 years ago

I've also pushed an unquoting of the special characters like $, {, }, @, (, ) to allow them to have the special function in the passed code. I was doing a test:

    evl @str-read-all $FD \; reply=\( "\${(@f)REPLY}" \)

and it revealed the need for such treating of the special characters.

psprint commented 4 years ago

The tests pass, so I'll merge the PR.

psprint commented 4 years ago

Or better not, other issues arose, I'll investigate them