Skip to content

Commit c8bd8ed

Browse files
committed
Minor fixes
1 parent 1db518c commit c8bd8ed

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

manuscript/BashScripting/scripts-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ Listing 3-9 shows the corrected version of the backup script. It handles an arbi
542542
{caption: "Listing 3-9. The script with an arbitrary number of input parameters", line-numbers: true, format: Bash}
543543
![`make-backup.sh`](code/BashScripting/make-backup.sh)
544544

545-
Bash has an alternative variable for `$@`. It is called `$*`. If you put it in double-quotes, Bash interprets its value as a single word. It interprets the `$@` variable as a set of words in the same case.
545+
Bash has an alternative variable for `$@`. It is called `$*`. If you put it in double quotes, Bash interprets its value as a single word. It interprets the `$@` variable as a set of words in the same case.
546546

547547
Here is an example to explain the difference between the `$@` and `$*` variables. Suppose you call the backup script this way:
548548
{line-numbers: false, format: Bash}

manuscript/BashScripting/tools.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Bash complains that you have passed too many parameters to `cd`. This command ex
8585

8686
You have two option to suppress the word splitting mechanism:
8787

88-
1. Enclose the path in double-quotes:
88+
1. Enclose the path in double quotes:
8989
{line-numbers: false, format: Bash}
9090
```
9191
cd "/c/Program Files"
@@ -116,14 +116,14 @@ Figure 3-3 shows that this command still fails.
116116
{caption: "Figure 3-3. Result of the `cd` command"}
117117
![cd result](images/BashScripting/cd-unexpected-token.png)
118118

119-
This is the same error message as Bash has printed when launching Notepad++ in Figure 3-1. This problem happens because of the parentheses. They are part of the Bash syntax. It means that the shell treats them as a language construct. We met this problem when grouping conditions of the `find` utility. Escaping or double-quotes solves this issue too. Here are possible solutions for our case:
119+
This is the same error message as Bash has printed when launching Notepad++ in Figure 3-1. This problem happens because of the parentheses. They are part of the Bash syntax. It means that the shell treats them as a language construct. We met this problem when grouping conditions of the `find` utility. Escaping or double quotes solves this issue too. Here are possible solutions for our case:
120120
{line-numbers: true, format: Bash}
121121
```
122122
cd /c/Program\ Files\ \(x86\)
123123
cd "/c/Program Files (x86)"
124124
```
125125

126-
Using double-quotes is simpler than escaping. Apply them to launch the Notepad++ this way:
126+
Using double quotes is simpler than escaping. Apply them to launch the Notepad++ this way:
127127
{line-numbers: false, format: Bash}
128128
```
129129
"/c/Program Files (x86)/Notepad++/notepad++.exe"

manuscript/BashScripting/variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ The `rm` utility deletes all files ending in `file.txt`. The globbing mechanism
136136
rm report_file.txt myfile.txt msg_file.txt
137137
```
138138

139-
When referencing a variable, always apply the double-quotes. They prevent unwanted Bash expansions. The quotes solve problems of both our examples:
139+
When referencing a variable, always apply double quotes. They prevent unwanted Bash expansions. The quotes solve problems of both our examples:
140140
{line-numbers: true, format: Bash}
141141
```
142142
filename1="my file.txt"
@@ -203,7 +203,7 @@ Here Bash tries to find and insert the variable called "prefix_". It happens bec
203203
cp "${prefix}_${name}" ~
204204
```
205205

206-
If you prefer to use the short form of the expansion, you have another option. Enclose each variable name in the double-quotes. Then Bash will not confuse them and nearby text. Here is an example:
206+
If you prefer to use the short form of the expansion, you have another option. Enclose each variable name in double quotes. Then Bash will not confuse them and nearby text. Here is an example:
207207
{line-numbers: false, format: Bash}
208208
```
209209
cp "$prefix"_"$name" ~

manuscript/BashShell/commands-info.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ echo 123
4141

4242
The dollar sign before a word tells Bash that it is a variable name. The interpreter handles it differently than a regular word. When Bash encounters a variable name in a command, it checks its variable list. If the name presents there, Bash inserts the variable value into the command. Otherwise, the interpreter places an empty string there.
4343

44-
I> Enclosing variable names in double-quotes is a [good practice](https://www.tldp.org/LDP/abs/html/quotingvar.html). This way, you avoid potential errors. There is an example. Bash replaces the variable name by its value. The value contains [**control characters**](https://en.wikipedia.org/wiki/Control_character). The interpreter handles these characters. As a result, the inserted variable's value differs from one that is stored in memory. This effect leads to incorrect behavior of the program. Double-quotes prevent Bash from processing strings.
44+
I> Enclosing variable names in double quotes is a [good practice](https://www.tldp.org/LDP/abs/html/quotingvar.html). This way, you avoid potential errors. There is an example. Bash replaces the variable name by its value. The value contains [**control characters**](https://en.wikipedia.org/wiki/Control_character). The interpreter handles these characters. As a result, the inserted variable's value differs from one that is stored in memory. This effect leads to incorrect behavior of the program. Double quotes prevent Bash from processing strings.
4545

4646
Let's come back to the `echo` command that prints the `PATH` variable. Figure 2-22 shows this output.
4747

manuscript/BashShell/extra-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ Here `xargs` constructs the following call of the `cp` utility:
658658
cp -t ~/tmp test file.txt
659659
```
660660

661-
The command copies the `test` and `file.txt` files to the `~/tmp` path. However, none of these files exists. The reason for the error is the word splitting mechanism. Bash splits lines in words by the spaces. You can disable the mechanism by double-quotes. Here is an example for our command:
661+
The command copies the `test` and `file.txt` files to the `~/tmp` path. However, none of these files exists. The reason for the error is the word splitting mechanism. Bash splits lines in words by the spaces. You can disable the mechanism using double quotes. Here is an example for our command:
662662
{line-numbers: false, format: Bash}
663663
```
664664
ls ~ | xargs -I % cp -t ~/tmp "%"

manuscript/BashShell/file-system.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ The first step is preparing the correct `find` call for searching the files. You
496496
find / -path "*/doc/bash/*" -name "*.html"
497497
```
498498

499-
When you pass the glob pattern to the `find` utility, always enclose it in double-quotes. The quotes do the same as the backslash before parentheses. They prevent Bash from expanding the patterns. Instead, Bash passes them to the `find` utility.
499+
When you pass the glob pattern to the `find` utility, always enclose it in double quotes. The quotes do the same as the backslash before parentheses. They prevent Bash from expanding the patterns. Instead, Bash passes them to the `find` utility.
500500

501501
Figure 2-17 shows the result of our `find` call. You can see that it found HTML files correctly.
502502

@@ -675,7 +675,7 @@ Using a text editor for checking dozens of files takes too much effort and time.
675675
grep "free software" /usr/share/doc/bash/README
676676
```
677677

678-
The first parameter of the utility is a string for searching. Always enclose it in the double-quotes. This way, you prevent Bash expansions and guarantee that the utility receives the string unchanged. Without the quotes, Bash splits the phrase into two separate parameters. This mechanism of splitting strings into words is called [**word splitting**](http://mywiki.wooledge.org/WordSplitting).
678+
The first parameter of the utility is a string for searching. Always enclose it in double quotes. This way, you prevent Bash expansions and guarantee that the utility receives the string unchanged. Without the quotes, Bash splits the phrase into two separate parameters. This mechanism of splitting strings into words is called [**word splitting**](http://mywiki.wooledge.org/WordSplitting).
679679

680680
The second parameter of `grep` is a relative or absolute path to the file. If you specify a list of files separated by spaces, the utility processes them all. In the example, we passed the `README` file path only.
681681

@@ -726,7 +726,7 @@ echo ~/*
726726

727727
Run these commands. The first one lists files and subdirectories of the current directory. The second command does the same for the home directory.
728728

729-
Do not enclose search patterns in double-quotes. Here is an example of the wrong command:
729+
Do not enclose search patterns in double quotes. Here is an example of the wrong command:
730730
{line-numbers: false, format: Bash}
731731
```
732732
grep "free software" "*"

0 commit comments

Comments
 (0)