feat(runner): add support for non-sudo in 'r' flag#3162
feat(runner): add support for non-sudo in 'r' flag#3162fwam wants to merge 1 commit intoranger:masterfrom
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.
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.
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.
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