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

Error with backslashes in unquoted variables with globbing off #698

Closed
Crestwave opened this issue Apr 7, 2020 · 6 comments
Closed

Error with backslashes in unquoted variables with globbing off #698

Crestwave opened this issue Apr 7, 2020 · 6 comments

Comments

@Crestwave
Copy link
Contributor

Required for #679.

osh$ var='\'
osh$ set -f
osh$ echo $var
Traceback (most recent call last):
  File "/home/usr/oil/bin/oil.py", line 996, in <module>
    sys.exit(main(sys.argv))
  File "/home/usr/oil/bin/oil.py", line 942, in main
    return AppBundleMain(argv)
  File "/home/usr/oil/bin/oil.py", line 915, in AppBundleMain
    status = ShellMain('osh', argv0, main_argv, login_shell)
  File "/home/usr/oil/bin/oil.py", line 717, in ShellMain
    prompt_plugin, errfmt)
  File "/home/usr/oil/core/main_loop.py", line 98, in Interactive
    is_return, _ = cmd_ev.ExecuteAndCatch(node)
  File "/home/usr/oil/osh/cmd_eval.py", line 1439, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/usr/oil/osh/cmd_eval.py", line 1323, in _Execute
    status, check_errexit = self._Dispatch(node)
  File "/home/usr/oil/osh/cmd_eval.py", line 535, in _Dispatch
    cmd_val = self.word_ev.EvalWordSequence2(words, allow_assign=True)
  File "/home/usr/oil/osh/word_eval.py", line 1850, in EvalWordSequence2
    self._EvalWordFrame(frame, strs)
  File "/home/usr/oil/osh/word_eval.py", line 1611, in _EvalWordFrame
    self.globber.Expand(a, argv)
  File "/home/usr/oil/osh/glob_.py", line 373, in Expand
    out.append(GlobUnescape(arg))
  File "/home/usr/oil/osh/glob_.py", line 129, in GlobUnescape
    assert i != n - 1, 'Trailing backslash: %r' % s
AssertionError: Trailing backslash: '\\'
@andychu
Copy link
Contributor

andychu commented Apr 7, 2020

OK thanks, this is also #628 with a slightly different repro, need to fix this! Although I hope I don't have to rewrite too much code to do it.

andychu pushed a commit that referenced this issue Apr 7, 2020
@andychu andychu closed this as completed in 7243d9d Apr 7, 2020
@andychu andychu reopened this Apr 7, 2020
@andychu
Copy link
Contributor

andychu commented Apr 7, 2020

I technically fixed this specific case, although there are some other bugs in this area and code needs a lot of work in general (see commit description)

@Crestwave
Copy link
Contributor Author

Yes, this still isn't enough for #679:

$ var='\e'
$ set -f
$ echo $var
\e
osh$ var='\e'
osh$ set -f
osh$ echo $var
e

@andychu andychu mentioned this issue Apr 15, 2020
5 tasks
andychu pushed a commit that referenced this issue Apr 15, 2020
- spec/glob: #698
- spec/var-op-strip: #702

Reported by Crestwave.
andychu pushed a commit that referenced this issue Apr 15, 2020
Bug #698.

The nested 'else' case was messed up!  Gah.
@andychu
Copy link
Contributor

andychu commented Apr 15, 2020

Actually I fixed this without doing the big refactoring I was afraid of! woohoo

@Crestwave
Copy link
Contributor Author

Great! Not sure if there are some cornercases where it doesn't work without #701 resolved, but it now runs on my machine with some upstreamable patches! I've opened a PR: dylanaraps/neofetch#1442

@andychu
Copy link
Contributor

andychu commented Apr 16, 2020

Awesome, thanks for sending the patch! I was about to check see what was left in the patch but you beat me to it :)

@andychu andychu closed this as completed Apr 19, 2020
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

2 participants