Bug 247410 - sh(1): Document that if the dot command fails to find and source the file, the whole script fails
Summary: sh(1): Document that if the dot command fails to find and source the file, th...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2020-06-19 09:42 UTC by Mateusz Piotrowski
Modified: 2020-06-19 14:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Piotrowski freebsd_committer 2020-06-19 09:42:55 UTC
Let's consider the following script:

```
echo 1
[ 
echo 2
. /nonexistent
echo 3
```

The output of the script is:

```
1
[: missing ]
2
.: cannot open /nonexistent: No such file or directory
```

As we can see, the dot builtin does aborts the script if it cannot source the desired file, while some other builtins, like [ in this example, just print an error message and let the script proceed.

We should probably document this behavior.