Skip to content

unable to identify shebang when it has initial spaces #1690

@honggyukim

Description

@honggyukim

uftrace detects shebang in the first line as follows.

#!/usr/bin/env python3

But if it has some whitespaces at the beginning, it can't detect the shebang as follows.

#! /usr/bin/env python3

For example, when there is a script as follows.

$ cat p-abc.py
#! /usr/bin/env python3

import os

def c():
    return os.getpid()

def b():
    return c()

def a():
    return b()

a()

The tracing result looks as follows.

$ uftrace p-abc.py
uftrace: /home/honggyu/work/uftrace/cmds/record.c:1580:find_in_path
 ERROR: Cannot trace '': No such executable file.

The shebang with whitespaces is legal so we should fix our shebang detection logic.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions