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

Always use >> instead of > when appending to a file #400

Open
mamekoro opened this issue Feb 22, 2024 · 0 comments
Open

Always use >> instead of > when appending to a file #400

mamekoro opened this issue Feb 22, 2024 · 0 comments

Comments

@mamekoro
Copy link

mamekoro commented Feb 22, 2024

sftp/files/entrypoint

Lines 37 to 38 in eacf693

# Append mounted config to final config
grep -v -E "$reArgSkip" < "$userConfPath" > "$userConfFinalPath"

According to the comment (# Append mounted config to final config), the intention of this code is to append, not overwrite.
Shouldn't it be >> "$userConfFinalPath", not > "$userConfFinalPath"?

EDIT:
I just realized that it is the first code that may create the $userConfFinalPath file, and that it does not overwrite any existing configuration.

Nevertheless, we should use >> rather than > as a convention when we intend to append rather than overwrite.

This is because the code > "$userConfFinalPath" can cause confusing bugs when the code is changed in the future or when a third party clones this repository and changes the code.

@mamekoro mamekoro changed the title entrypoint unexpectedly overwrites final config Always use >> instead of > when appending to a file Feb 22, 2024
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

1 participant