pub fn parse_shebang<R: Read>(reader: R) -> Result<ShebangTuple>Expand description
Parse a shebang line from a reader and return raw shebang components.
This function reads the first line from the provided reader and parses it as a shebang line to extract raw command components, similar to Python’s identify.parse_shebang().
§Arguments
reader- A reader providing the file content
§Returns
A vector of raw shebang components. Returns an empty vector if no valid shebang is found.
§Examples
use file_identify::parse_shebang;
use std::io::Cursor;
let shebang = Cursor::new(b"#!/usr/bin/env python3\nprint('hello')");
let components = parse_shebang(shebang).unwrap();
assert_eq!(components.get(0).unwrap(), "python3");
let no_shebang = Cursor::new(b"print('hello')");
let components = parse_shebang(no_shebang).unwrap();
assert!(components.is_empty());