Skip to content

Commit 250bd6a

Browse files
authored
Merge pull request google#534 from google/change_HEAD
Project import generated by Copybara.
2 parents 056962e + 7c26f83 commit 250bd6a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

shellguide.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ information is recommended.
132132

133133
```shell
134134
err() {
135-
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" > &2
135+
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
136136
}
137137

138138
if ! do_something; then
@@ -758,6 +758,7 @@ removed `./somefile'
758758

759759
`eval` should be avoided.
760760

761+
761762
Eval munges the input when used for assignment to variables and can
762763
set variables without making it possible to check what those variables
763764
were.
@@ -1146,15 +1147,13 @@ my_func2() {
11461147
### Function Location
11471148
11481149
Put all functions together in the file just below constants. Don't hide
1149-
executable code between functions.
1150+
executable code between functions. Doing so makes the code difficult to follow
1151+
and results in nasty surprises when debugging.
11501152

11511153
If you've got functions, put them all together near the top of the
11521154
file. Only includes, `set` statements and setting constants
11531155
may be done before declaring functions.
11541156
1155-
Don't hide executable code between functions. Doing so makes the code
1156-
difficult to follow and results in nasty surprises when debugging.
1157-
11581157
<a id="s7.8-main"></a>
11591158
11601159
### main
@@ -1193,14 +1192,14 @@ Example:
11931192
11941193
```shell
11951194
if ! mv "${file_list[@]}" "${dest_dir}/"; then
1196-
echo "Unable to move ${file_list[*]} to ${dest_dir}" > &2
1195+
echo "Unable to move ${file_list[*]} to ${dest_dir}" >&2
11971196
exit 1
11981197
fi
11991198
12001199
# Or
12011200
mv "${file_list[@]}" "${dest_dir}/"
12021201
if (( $? != 0 )); then
1203-
echo "Unable to move ${file_list[*]} to ${dest_dir}" > &2
1202+
echo "Unable to move ${file_list[*]} to ${dest_dir}" >&2
12041203
exit 1
12051204
fi
12061205
```
@@ -1213,7 +1212,7 @@ following is acceptable:
12131212
```shell
12141213
tar -cf - ./* | ( cd "${dir}" && tar -xf - )
12151214
if (( PIPESTATUS[0] != 0 || PIPESTATUS[1] != 0 )); then
1216-
echo "Unable to tar files to ${dir}" > &2
1215+
echo "Unable to tar files to ${dir}" >&2
12171216
fi
12181217
```
12191218

0 commit comments

Comments
 (0)