Skip to content

Commit

Permalink
Passing arguments in shebang on Linux (env -S)
Browse files Browse the repository at this point in the history
It is possible to pass arguments into commands in the shebang on Linux using the env(1) -S option.
  • Loading branch information
sheeit authored Nov 17, 2021
1 parent 3a2848c commit f3bced1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,17 @@ console.log("Hello, world!")
```

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

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

Instead, specify all ts-node options in your `tsconfig.json`.
#!/usr/bin/env ts-node --files

- On Linux:

#!/usr/bin/env -S ts-node --files

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.

## Programmatic

Expand Down

0 comments on commit f3bced1

Please sign in to comment.