Skip to content

Use nob.c as an example of C compatible shebang for Linux.#259

Open
SrBurns-rep wants to merge 1 commit into
tsoding:mainfrom
SrBurns-rep:main
Open

Use nob.c as an example of C compatible shebang for Linux.#259
SrBurns-rep wants to merge 1 commit into
tsoding:mainfrom
SrBurns-rep:main

Conversation

@SrBurns-rep

Copy link
Copy Markdown

Motivation

For me nob.c is more than a test suite, it's an example for users of nob.h, as this double slash feature is underappreciated it would be great to share this to the users.

Where it works

This should only work with an env executable that is located in /usr/bin and supports the -S flag on OSes that support the double forward slash as a shebang (This feature is implemented on recent Linux kernels). On other cases this should be ignored as a comment or cause an indecipherable error.

How the shebang works

Upon execution the Kernel Program Loader will parse the double slash and find the program starting from the root directory, if found it will execute it, the rest of the work is on env that parses the executed line and create a valid command to pass to the shell.
Sorry if something on this explanation is missing, I did this PR in a hurry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant