Skip to content

Commit f3bced1

Browse files
authored
Passing arguments in shebang on Linux (env -S)
It is possible to pass arguments into commands in the shebang on Linux using the env(1) -S option.
1 parent 3a2848c commit f3bced1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,17 @@ console.log("Hello, world!")
162162
```
163163

164164
Passing CLI arguments via shebang is allowed on Mac but not Linux. For example, the following will fail on Linux:
165+
### Passing CLI arguments via shebang
165166

166-
#!/usr/bin/env ts-node --files
167-
// This shebang is not portable. It only works on Mac
167+
- On Mac:
168168

169-
Instead, specify all ts-node options in your `tsconfig.json`.
169+
#!/usr/bin/env ts-node --files
170+
171+
- On Linux:
172+
173+
#!/usr/bin/env -S ts-node --files
174+
175+
The `-S` option for `env` processes and splits what comes after it into separate arguments; and is used to pass multiple arguments on shebang lines.
170176

171177
## Programmatic
172178

0 commit comments

Comments
 (0)