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

Add Warning Prompt for File Write Operations in Elixir Learning Documentation #13557

Merged
merged 3 commits into from
May 14, 2024

Conversation

eastack
Copy link
Contributor

@eastack eastack commented May 14, 2024

When I was following the documentation to learn Elixir just now, I entered the following code in iex: {:ok, file} = File.open("/home/username/.zshrc", [:write]). This ended up clearing my .zshrc configuration file. Fortunately, I had a backup. However, if others don't have a backup or input the path to a more important file, I understand this could result in their files being cleared. Therefore, I added a warning prompt when dealing with File.open("path/to/file/hello", [:write]). English is not my native language, and I used AI to translate these prompts. Feel free to modify if it's not good enough, but I feel it's necessary to give readers a heads-up, as there's still some risk involved.

@sabiwara
Copy link
Contributor

Thanks for the pull-request @eastack.

Alternative idea: Maybe we could use a path like /tmp/elixir_getting_started.txt so that the reader doesn't need to come up with a path in the first place?

@eastack
Copy link
Contributor Author

eastack commented May 14, 2024

Here, due to the diverse audience (e.g., Windows users), there's always a risk of varying interpretations of this code. However, perhaps we could consider using [:append] instead of [:write]? What do you think? (This appears to be relatively safer. If readers understand why/how to change :append to :write, then they likely understand what they're doing). @sabiwara

@josevalim josevalim merged commit ed4cc33 into elixir-lang:main May 14, 2024
1 check passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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

Successfully merging this pull request may close these issues.

3 participants