File tree Expand file tree Collapse file tree 1 file changed +15
-19
lines changed Expand file tree Collapse file tree 1 file changed +15
-19
lines changed Original file line number Diff line number Diff line change 4
4
5
5
arguments
6
6
name (1 ,1 ) string {mustBeNonzeroLengthText }
7
- fpath string = getenv(' PATH' )
7
+ fpath ( 1 , : ) string = getenv(' PATH' )
8
8
subdir (1 ,: ) string {mustBeNonempty } = " "
9
9
end
10
10
11
11
import stdlib.fileio.is_exe
12
-
13
- exe = string .empty ;
12
+ import stdlib .fileio .expanduser
14
13
15
14
if ispc
16
15
pathext = " .exe" ;
17
16
if ~endsWith(name , pathext )
18
- name = [ name + pathext , name ] ;
17
+ name = name + pathext ;
19
18
end
20
19
end
21
20
22
- if any( strlength(fileparts(name )) > 0 )
21
+ if strlength(fileparts(name )) > 0
23
22
% has directory part
24
- for n = name
25
- if is_exe(n )
26
- exe = n ;
27
- break
28
- end
23
+ if is_exe(name )
24
+ exe = name ;
25
+ return
29
26
end
30
- return
31
27
end
32
28
33
- fpath = split(stdlib .fileio .expanduser(fpath ), pathsep ).' ;
29
+ if isscalar(fpath )
30
+ fpath = split(expanduser(fpath ), pathsep ).' ;
31
+ end
34
32
fpath = fpath(strlength(fpath )>0);
35
33
36
34
if ispc
40
38
41
39
for p = fpath
42
40
for s = subdir
43
- for n = name
44
- e = fullfile(p , s , n );
45
- if is_exe(e )
46
- exe = e ;
47
- return
48
- end
41
+ exe = fullfile(p , s , name );
42
+ if is_exe(exe )
43
+ return
49
44
end
50
45
end
51
-
52
46
end
53
47
48
+ exe = string .empty ;
49
+
54
50
end
You can’t perform that action at this time.
0 commit comments