Skip to content

Commit

Permalink
[errors] Quote filenames for unambiguous parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Oct 4, 2021
1 parent 7c577c8 commit 98995e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from osh import word_
from mycpp import mylib
from mycpp.mylib import tagswitch, NewStr
from qsn_ import qsn

from typing import List, Optional, cast, Any, TYPE_CHECKING
if TYPE_CHECKING:
Expand Down Expand Up @@ -116,10 +117,13 @@ def GetLineSourceString(arena, line_id):

elif case(source_e.MainFile):
src = cast(source__MainFile, UP_src)
s = src.path
# This will quote a file called '[ -c flag ]' to disambiguate it!
# also handles characters that are unprintable in a terminal.
s = qsn.maybe_encode(src.path)
elif case(source_e.SourcedFile):
src = cast(source__SourcedFile, UP_src)
s = src.path
# ditto
s = qsn.maybe_encode(src.path)

elif case(source_e.ArgvWord):
src = cast(source__ArgvWord, UP_src)
Expand Down

0 comments on commit 98995e3

Please sign in to comment.