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

single quotes in $PGBK_OPTS are not handled as expected #24

Closed
neiaberau opened this issue Apr 20, 2019 · 3 comments
Closed

single quotes in $PGBK_OPTS are not handled as expected #24

neiaberau opened this issue Apr 20, 2019 · 3 comments

Comments

@neiaberau
Copy link

neiaberau commented Apr 20, 2019

if the for example -T 'tmp*' is used in PGBK_OPTS, the table is not excluded, this only seems to work if eval is used.
instead of:
if ! ${PGBK_BIN}pg_dump $OPTS $PGBK_OPTS -f "${dump}" $db; then
this could work (not yet tested for all cases, also need to handle spaces in $dump)
if ! eval "${PGBK_BIN}pg_dump $OPTS $PGBK_OPTS -f ${dump} $db"; then

@orgrim
Copy link
Owner

orgrim commented Apr 24, 2019

Hello,

If you remove the singles quotes, the tables are excluded: PGBK_OPTS="-Fc -T tmp*"

To handle spaces correctly, PGBK_OPTS must become an array with each single argument quoted as its elements. Then pg_dump must be called with "${PGBK_OPTS[@]}". This is the only clean and secure way to handle spaces. Of course, it would break backward compatibility...

Regards,

@neiaberau
Copy link
Author

neiaberau commented Apr 24, 2019

I had the single quotes in my original setup, as the documentation of postgres said so.

Removing them should work most of the time I guess, however would that not, if by chance a file named tmp… exists, expanded to the filename?

But of course, you are absolutely right, the array solution would be the only way to treat arguments safely. With the caveat of backward compatibility

@orgrim
Copy link
Owner

orgrim commented Apr 24, 2019

Indeed it is expanded. So I guess the array is the only way to go...

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

No branches or pull requests

2 participants