Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp config create - Too many positional arguments #55

Closed
adampatterson opened this issue Apr 18, 2018 · 7 comments
Closed

wp config create - Too many positional arguments #55

adampatterson opened this issue Apr 18, 2018 · 7 comments

Comments

@adampatterson
Copy link

Ubuntu 14
CLI 1.5
PHP 5.5.9

This might be my lack of knowledge in the command line.

But

wp config create --dbname=db_name --dbuser=username --dbpass=password --dbhost='127.0.0.1'

will result in Too many positional arguments

wp config create --dbname=db_name --dbuser='username' --dbpass='password' --dbhost='127.0.0.1'

Placing DB user, password, and host in single quotes worked. The same goes for the core install command.

I didn't see this in any of the docs or the CLI help text.

https://developer.wordpress.org/cli/commands/config/create/
https://developer.wordpress.org/cli/commands/core/install/

@schlessera
Copy link
Member

@adampatterson This is just part of the normal shell behavior.
Some characters have a special meaning, like for example the "space" character to separate parameters.

If you want to use such characters inside of a value, you have to "quote" the value to let the shell know that it should just accept the characters as part of the value, instead of interpreting them.

So, --username=schlessera would work, whereas --username=Alain Schlesser would not work. The shell will see two arguments in that case: --username=Alain & Schlesser. To let the shell know that it should not interpret the "space" character, you put the value in quotes: --username="Alain Schlesser" or --username='Alain Schlesser'.

@adampatterson
Copy link
Author

OK cool, But is this expected for usernames and passwords? I didn't have any spaces and it still had issues. Unless the wrapping the dbhost fixed it and I added single quotes to the rest of the arguments.

@schlessera
Copy link
Member

There are other characters that need to be quoted or escaped as well. The exact list of characters depends on the shell and environment you're using.

Here's a non-exhaustive list of characters that generally need to be escaped or quoted in the shell:

!"$&'()*,:;<=>?@[\]^`{|}

@adampatterson
Copy link
Author

Thanks for the tips/help!

My passwords did contain special characters so it makes sense then.

@RewriteThis
Copy link

I just got this error trying to restrict posts to just those with an ID less than something. I used ID<##

@hmbashar
Copy link

You cannot use spaces in a title or text. Instead, you can use a hyphen (-) like WP-CLI-Test, or you can use quotation marks like "WP CLI Test". Please check the attached file for reference.
Screenshot at Jun 25 12-33-11 PM

@codewizard13
Copy link

You cannot use spaces in a title or text. Instead, you can use a hyphen (-) like WP-CLI-Test, or you can use quotation marks like "WP CLI Test". Please check the attached file for reference.

Having similar issue. I know this is how it is supposed to work, but neither using single quotes, nor double quotes, nor escaping spaces manually with backslashes worked. Here are some permutations of my wp core install command (none worked):

With no escaping:

wp core install --title=EH SSH Install Test --admin_user=myadmin [email protected] --prompt=admin_password < admin_password.txt --color

With quoted escaped double quotes:

wp core install --title="\"EH SSH Install Test\"" --admin_user=myadmin [email protected] --prompt=admin_password < admin_password.txt --color

With single quotes:

wp core install --title='EH SSH Install Test' --admin_user=myadmin [email protected] --prompt=admin_password < admin_password.txt --color

With double quotes:

wp core install --title="EH SSH Install Test" --admin_user=myadmin [email protected] --prompt=admin_password < admin_password.txt --color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants