Skip to content

Commit 9b217d6

Browse files
CopilotBillWagner
andauthored
Update shebang directive to use portable env format (#49932)
* Initial plan * Update shebang directive to use portable env format Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
1 parent ccf8453 commit 9b217d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/csharp/language-reference/preprocessor-directives.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ The C# compiler ignores any preprocessor directive that starts with `#:` or `#!`
5656
The `#!` preprocessor directive enables unix shells to directly execute a C# file using `dotnet run`. For example:
5757

5858
```csharp
59-
#!/usr/local/share/dotnet/dotnet run
59+
#!/usr/bin/env dotnet run
6060
Console.WriteLine("Hello");
6161
```
6262

63-
The preceding code snippet informs a Unix shell to execute the file using `/usr/local/share/dotnet/dotnet run`. (Your installation directory for the `dotnet` CLI can be different on different Unix or macOS distributions). The `#!` line must be the first line in the file, and the following tokens are the program to run. You need to enable the *execute* (`x`) permission on the C# file for that feature.
63+
The preceding code snippet informs a Unix shell to execute the file using `dotnet run`. The `/usr/bin/env` command locates the `dotnet` executable in your PATH, making this approach portable across different Unix and macOS distributions. The `#!` line must be the first line in the file, and the following tokens are the program to run. You need to enable the *execute* (`x`) permission on the C# file for that feature.
6464

6565
The `#:` directives that are used in file-based apps include:
6666

0 commit comments

Comments
 (0)