Fix caps, highlighting, and spelling of brand names.

John Gardner
2021-12-22 18:56:34 +11:00
parent a299d82a6f
commit dcdf85d787

@@ -2,7 +2,7 @@
### Problematic code: ### Problematic code:
```sh ```console
$ cat -v myscript $ cat -v myscript
#!/bin/sh^M #!/bin/sh^M
echo "Hello World"^M echo "Hello World"^M
@@ -10,20 +10,23 @@ echo "Hello World"^M
### Correct code: ### Correct code:
```sh ```console
$ cat -v myscript $ cat -v myscript
#!/bin/sh #!/bin/sh
echo "Hello World" echo "Hello World"
``` ```
### Rationale: ### Rationale:
The script uses Windows/DOS style `\r\n` line terminators instead of UNIX style `\n` terminators. The additional `\r` aka `^M` aka carriage return characters will be treated literally, and results in all sorts strange bugs and messages. The script uses Windows/MS-DOS style `\r\n` line terminators instead of Unix-style `\n` terminators. The additional `\r` aka `^M` aka carriage return characters will be treated literally, and results in all sorts strange bugs and messages.
You can verify this with `cat -v yourfile` and see whether or not each line ends with a `^M`. To delete them, open the file in your editor and save the file as "Unix", "UNIX/OSX Format", `:set ff=unix` or similar if it supports it. You can verify this with `cat -v yourfile` and see whether or not each line ends with a `^M`. To delete them, open the file in your editor and save the file as "Unix", "Unix/macOS Format", `:set ff=unix` or similar if it supports it.
If you don't know how to get your editor to save a file with Unix line terminators, you can use `tr`: If you don't know how to get your editor to save a file with Unix line terminators, you can use `tr`:
```sh
tr -d '\r' < badscript > goodscript tr -d '\r' < badscript > goodscript
```
This will read a script `badscript` with possible carriage returns, and write `goodscript` without them. This will read a script `badscript` with possible carriage returns, and write `goodscript` without them.
@@ -33,6 +36,5 @@ None
### Related resources: ### Related resources:
* [BashFaq: How do I convert a file from DOS format to UNIX format (remove CRs from CR-LF line terminators)?](https://mywiki.wooledge.org/BashFAQ/052) * [BashFaq: How do I convert a file from MS-DOS format to Unix format (remove CRs from CR-LF line terminators)?](https://mywiki.wooledge.org/BashFAQ/052)
* [StackOverflow: Are shell scripts sensitive to encoding and line endings? * [StackOverflow: Are shell-scripts sensitive to encoding and line-endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings)
](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings)