简体   繁体   中英

Is a space allowed between #! and the first character of the path?

In the language i work with, "#" does not start a comment. So i have to find a way to pass the first shebang line without yielding an error. A trick could do the job provided that some space is/are allowed after the heading #, i mean writting

#! /usr/path/to/the/bin/to/call/to/run/me

instead of

#!/usr/path/to/the/bin/to/call/to/run/me

I have no linux installation available to do the test myself.

Would this shebang work?

The shebang ( # ) is a 16-bit kernel-interpreted magic "number" (actually 0x23 0x21 ). Thereafter, the kernel program loader (following the exec -family call) attempts to execute the remainder of the line to handle the remainder of the containing file's content. Many, if not most modern kernels disregard preceding spaces to the command that follows the shebang. As such, # /bin/bash , # /usr/bin/perl , and the like, should be acceptable with most modern kernels. That said, a shebang with no following space is far more commonly seen.

Note, and FYI, the executable and linkable format (ELF) magic number is 32-bits: 0x7F 0x45 0x4C 0x46 or [DEL] [E] [L] [F] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM