⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

parse_shebang

Function parse_shebang 

Source
pub fn parse_shebang(data: &[u8]) -> Option<(String, Option<String>)>
Expand description

Parse a shebang (#!) line from the beginning of a file

If the data starts with #!, extracts the interpreter path and optional argument from the first line (up to 256 bytes or first newline).

§Examples

  • #!/bin/sh\n -> Some((“/bin/sh”, None))
  • #!/bin/sh -e\n -> Some((“/bin/sh”, Some(“-e”)))
  • #!/usr/bin/env python3\n -> Some((“/usr/bin/env”, Some(“python3”)))
  • \x7fELF... -> None (not a shebang)