code-server icon indicating copy to clipboard operation
code-server copied to clipboard

[Docs]: Change sed to one line to avoid overwriting config backup

Open jrsec opened this issue 1 year ago • 1 comments

What is your suggestion?

These lines result in overwriting the ~/.config/code-server/config.yaml.bak file between the two sed commands when line 245 is run. https://github.com/coder/code-server/blob/262f66abf6a5d96b2e50c5681baabbf18d6dfa38/docs/guide.md?plain=1#L242-L245

coder_1

They could be replaced with:

sed -i.bak -e 's/cert: false/cert: true/' `# Replaces "cert: false" with "cert: true" in the code-server config.`\
-e 's/bind-addr: 127.0.0.1:8080/bind-addr: 0.0.0.0:443/' `# Replaces "bind-addr: 127.0.0.1:8080" with "bind-addr: 0.0.0.0:443" in the code-server config.`\
~/.config/code-server/config.yaml

How will this improve the docs?

The suggested command runs sed only once and therefore backs up the config file only once, avoiding overwriting the original backup from line 243.

coder_2

Are you interested in submitting a PR for this?

Sure, it's a simple change.

jrsec avatar Oct 04 '23 17:10 jrsec

Makes sense. To be honest I am pretty sure the only reason we even have .bak in there at all is so the command works with both GNU and BSD sed. Apparently -i'' works on both (creates no backup) so that is another option.

But if folks find the backup helpful, I am not opposed to keeping it and making this one command. Happy to merge whichever.

code-asher avatar Oct 04 '23 23:10 code-asher

Closing for now, still happy to take a PR but I think maybe two commands is nice for readability and in case you need to change only one of those values, and it is more copyable if you need to change other values.

code-asher avatar Jul 13 '24 00:07 code-asher