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

Fix "sync_git_repo_from_pc1_to_pc2.sh" script's usage of printf #5

Open
ElectricRCAircraftGuy opened this issue Mar 24, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ElectricRCAircraftGuy
Copy link
Owner

Apparently you should never pass variables containing arbitrary text to printf as part of the format string, because if they contain any % characters, printf will try to interpret them as a format sequence for a following variable, and will throw an error. Instead, pass variables to printf only as arguments required by a manually-specified format string.

Ex: use

printf '%s\n%s\n%s\n' "$text_foo" "$text_bar" "$baz"

OR (same thing apparently)

printf '%s\n' "$text_foo" "$text_bar" "$baz"

Instead of:

printf "${text_foo}\n${text_bar}\n${baz}"

See the comments under my answer here: https://stackoverflow.com/questions/29933349/how-can-i-make-git-commit-messages-divide-into-multiple-lines/60826932#60826932

and also do some googling on how to properly use variables in bash printf statements.

@ElectricRCAircraftGuy ElectricRCAircraftGuy self-assigned this Mar 24, 2020
@ElectricRCAircraftGuy ElectricRCAircraftGuy added the bug Something isn't working label Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant