Guseyn Ismayylov
Guseyn Ismayylov

Reputation: 393

Yaml with bash: escaping quotes in string

I want to execute command in travis file, it's executed by bash from yaml configuration file:

before_script:
 - psql -c 'create role "user" WITH LOGIN PASSWORD '1234'' -U postgres

But apparently I get the error: ERROR: syntax error at or near ""1234"" and I just don't know how to escape quotes: '

Upvotes: 2

Views: 1516

Answers (2)

Soman Dubey
Soman Dubey

Reputation: 3906

Sometimes its better to validate YAML syntax and it might surprise you with reasons its failing:

Use this great tool: YAML Formatter

Upvotes: 1

Zeitounator
Zeitounator

Reputation: 44615

This is not a yaml issue, it only concerns the shell launched by your travis build.

Single quotes inside single quotes in a shell string are escaped as a double single quotes (see this link out of many others for more info)

psql -c 'create role "user" WITH LOGIN PASSWORD ''1234''' -U postgres

Upvotes: 1

Related Questions