fsfe / reuse-tool

reuse is a tool for compliance with the REUSE recommendations.
https://reuse.software
376 stars 144 forks source link

Annotation crashes on shebang #958

Closed carmenbianca closed 3 months ago

carmenbianca commented 4 months ago

The following terminal extract contains all relevant information:

(protokolo-py3.11) 🐚 carmenbianca protokolo i18n $ cat generate_pot.sh
#!/usr/bin/env sh
(protokolo-py3.11) 🐚 carmenbianca protokolo i18n $ reuse annotate --copyright 'me' generate_pot.sh
Traceback (most recent call last):
  File "/home/carmenbianca/.cache/pypoetry/virtualenvs/protokolo-Gp8COqWt-py3.11/bin/reuse", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/carmenbianca/.cache/pypoetry/virtualenvs/protokolo-Gp8COqWt-py3.11/lib/python3.11/site-packages/reuse/_main.py", line 310, in main
    return parsed_args.func(parsed_args, project, out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/carmenbianca/.cache/pypoetry/virtualenvs/protokolo-Gp8COqWt-py3.11/lib/python3.11/site-packages/reuse/_annotate.py", line 523, in run
    result += add_header_to_file(
              ^^^^^^^^^^^^^^^^^^^
  File "/home/carmenbianca/.cache/pypoetry/virtualenvs/protokolo-Gp8COqWt-py3.11/lib/python3.11/site-packages/reuse/_annotate.py", line 170, in add_header_to_file
    output = find_and_replace_header(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/carmenbianca/.cache/pypoetry/virtualenvs/protokolo-Gp8COqWt-py3.11/lib/python3.11/site-packages/reuse/header.py", line 278, in find_and_replace_header
    before, after = _extract_shebang(shebang, after)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/carmenbianca/.cache/pypoetry/virtualenvs/protokolo-Gp8COqWt-py3.11/lib/python3.11/site-packages/reuse/header.py", line 221, in _extract_shebang
    return (shebang, text)
            ^^^^^^^
UnboundLocalError: cannot access local variable 'shebang' where it is not associated with a value
(protokolo-py3.11) 🐚 carmenbianca protokolo i18n $ reuse --version
reuse 3.0.1