Automattic/vip-quickstart — pull request #174 by pdclark (2014-05-07 09:33:43+00:00)
Title: Filter arguments passed to bin/wp proxy to allow spaces

**Issue**

Attempting to pass any argument or flag value with a space in it fails with the error `Too many positional arguments`. This is because bash's `$@`argument reference strips original quoting syntax.

**Use case**

Any of these will show the problem:
```
wp option add test123 "foo bar baz"
wp option add test123 'foo bar baz'
wp option add test123 foo\ bar\ baz

wp export --dir="/path with/some spaces/"
wp export --dir='/path with/some spaces/'
wp export --dir=/path\ with/some\ spaces/
```

This becomes increasing critical for plugins like VIP Scanner, where required arguments contain spaces:

`wp vip-scanner scan-theme --theme="twentyfourteen" --scan_type="VIP Theme Review"`

**Solution**

Use awk to add quotes back to arguments that contain spaces, giving special treatment to --flag=value syntax.

**Test script**

`wp test-wp-filter escaped\ space --long_flag-name="foo bar" --single-quotes='foo bar' --escaped=foo\ bar --no-equals "foo bar" no quotes here "Escaping \"double quotes\" is fine"`

Expected output:
```
'escaped space'
--long_flag-name='foo bar'
--single-quotes='foo bar'
--escaped='foo bar'
--no-equals
'foo bar'
no
quotes
here
'Escaping "double quotes" is fine'
```

**Test environment**

* VIP Quickstart d68e1a2
* WP-CLI `0.15.0`
* Mac OS `10.9.3`