Skip to content

Commit ada55d3

Browse files
committed
[emrun] Simplify which helper. NFC
1 parent 7f385f3 commit ada55d3

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

emrun.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,19 +1144,15 @@ def is_exe(fpath):
11441144
if is_exe(program):
11451145
return program
11461146
else:
1147-
for path in os.environ["PATH"].split(os.pathsep):
1147+
exe_suffixes = ['']
1148+
if WINDOWS and '.' not in fname:
1149+
exe_suffixes = ['.exe', '.cmd', '.bat']
1150+
for path in os.environ['PATH'].split(os.pathsep):
11481151
path = path.strip('"')
11491152
exe_file = os.path.join(path, program)
1150-
if is_exe(exe_file):
1151-
return exe_file
1152-
1153-
if WINDOWS and '.' not in fname:
1154-
if is_exe(exe_file + '.exe'):
1155-
return exe_file + '.exe'
1156-
if is_exe(exe_file + '.cmd'):
1157-
return exe_file + '.cmd'
1158-
if is_exe(exe_file + '.bat'):
1159-
return exe_file + '.bat'
1153+
for ext in exe_suffixes:
1154+
if is_exe(exe_file + ext):
1155+
return exe_file + ext
11601156

11611157
return None
11621158

0 commit comments

Comments
 (0)