-
Notifications
You must be signed in to change notification settings - Fork 909
feat(runner): add support for non-sudo in 'r' flag #3162
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
base: master
Are you sure you want to change the base?
Conversation
b8ce4f4 to
07437d2
Compare
| root_command = None | ||
| for tested_command in root_commands: | ||
| if tested_command not in get_executables(): | ||
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for x in seq:
if not condition:
continue
else:
# do smthCould it be simplified, avoiding one of if branches and continue?
for x in seq:
if condition:
# do smthBTW, an alternative way to reach the same result in a single assignment, instead of nested for + if:
root_command = next(
(cmd for cmd in root_commands if cmd in get_executables()),
None,
)generator expression is used to filter out elements, and
built-in next() is used to select first element of sequence, or None if empty
Just sharing a thought, it's up to personal taste whether to use this or for: if:
| else: | ||
| action = ['sudo'] + (f_flag and ['-b'] or []) + action | ||
| # TODO: 'f' flag for doas/run0 | ||
| match(root_command): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: match statements are added in Python 3.10
AFAIK (based on setup.py content), ranger is supporting Python 3.1 and even 2.7 😞
| if isinstance(action, str): | ||
| action = 'sudo ' + (f_flag and '-b ' or '') + action | ||
| else: | ||
| action = ['sudo'] + (f_flag and ['-b'] or []) + action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch (I assume, for when action is a list) has no correspondence in the new code. In the new code action is unconditionally treated as a str (concatenated with other strings).
Was this if branch unreachable?
ISSUE TYPE
CHECKLIST
CONTRIBUTINGdocument has been read [REQUIRED]DESCRIPTION
Add support for
doasandrun0in-rflag (no support forfflag yet.)MOTIVATION AND CONTEXT
Hard-coded
sudomight cause problems on systems wheresudoisn't installed.TESTING
IMAGES / VIDEOS