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

Check dir before listing - handle NotADirectoryError #224

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

Its-Just-Nans
Copy link
Contributor

@Its-Just-Nans Its-Just-Nans commented Jan 30, 2024

Hello

This produces a crash

touch file
rshell

ls file
# if we press [TAB] it's fine 

ls file/
# if we press [TAB] we get a NotADirectoryError

With this tiny PR, this fix that by checking if the path is really a directory

For info the full traceback is
Traceback (most recent call last):
  File "/home/n4n5/.local/lib/python3.10/site-packages/rshell/main.py", line 2018, in filename_complete
    return self.real_filename_complete(text, line, begidx, endidx)
  File "/home/n4n5/.local/lib/python3.10/site-packages/rshell/main.py", line 2095, in real_filename_complete
    paths = sorted(auto(listdir_matches, abs_match))
  File "/home/n4n5/.local/lib/python3.10/site-packages/rshell/main.py", line 606, in auto
    return func(dev_filename, *args, **kwargs)
  File "/home/n4n5/.local/lib/python3.10/site-packages/rshell/main.py", line 834, in listdir_matches
    for filename in os.listdir(dirname) if filename.startswith(match_prefix)]
NotADirectoryError: [Errno 20] Not a directory: '/tmp/tmp.7pssVtEk3J/file'

@dhylands dhylands merged commit c8a2cd7 into dhylands:master Feb 4, 2024
@dhylands
Copy link
Owner

dhylands commented Feb 4, 2024

Thanks for the fix

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

Successfully merging this pull request may close these issues.

None yet

2 participants