1
0
mirror of https://github.com/koalaman/shellcheck.git synced 2025-03-12 12:35:25 -07:00

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:
```sh
```console
$ cat -v myscript
#!/bin/sh^M
echo "Hello World"^M
@ -10,20 +10,23 @@ echo "Hello World"^M
### Correct code:
```sh
```console
$ cat -v myscript
#!/bin/sh
echo "Hello World"
```
### 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`:
tr -d '\r' < badscript > goodscript
```sh
tr -d '\r' < badscript > goodscript
```
This will read a script `badscript` with possible carriage returns, and write `goodscript` without them.
@ -33,6 +36,5 @@ None
### 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)
* [StackOverflow: Are shell scripts sensitive to encoding and line endings?
](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings)
* [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?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings)