Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case with /eggex/ can be confused with glob /foo/bar/* #2232

Open
andychu opened this issue Jan 15, 2025 · 3 comments
Open

case with /eggex/ can be confused with glob /foo/bar/* #2232

andychu opened this issue Jan 15, 2025 · 3 comments

Comments

@andychu
Copy link
Contributor

andychu commented Jan 15, 2025

https://oilshell.zulipchat.com/#narrow/channel/264891-oil-help/topic/glob.20starting.20with.20slash.20in.20case

@andychu
Copy link
Contributor Author

andychu commented Jan 15, 2025

crash in Python version

$ bin/ysh -c 'case ("/foo/bar/") { \/foo/* { echo hi } }'
Traceback (most recent call last):
  File "/home/andy/git/oils-for-unix/oils/bin/oils_for_unix.py", line 202, in <module>
    sys.exit(main(sys.argv))

@andychu
Copy link
Contributor Author

andychu commented Jan 15, 2025

Inconsistency in whether it is flagged, depending on the line

$ cat g.ysh
case ('/foo/bar') {
  \/foo/* { echo hi } 
}

$ cat g2.ysh
case ('/foo/bar') { \/foo/* { echo hi } }
$ ysh g.ysh

$ ysh g2.ysh
  case ('/foo/bar') { \/foo/* { echo hi } }
                      ^~
g2.ysh:1: Invalid char escape in unquoted word (OILS-ERR-13)

Expected: g.ysh should also give an error

@andychu
Copy link
Contributor Author

andychu commented Jan 15, 2025

Some how in the first case we are missing \ in the SQ node

$ ysh -n g.ysh
(command.Case case_kw:<KW_Case case> to_match:(case_arg.YshExpr e:(SQ /foo/bar)) arms_start:<Lit_LBrace "{"> arms:[] arms_end:<Lit_RBrace "}">)
andy@hoover:~/git/oils-for-unix/oils$ ysh g.ysh
andy@hoover:~/git/oils-for-unix/oils$ cat g.ysh
case ('/foo/bar') {
  \/foo/* { echo hi } 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant