File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -125,16 +125,30 @@ pub fn resolve_executable(exec: &Path) -> Result<PathBuf> {
125
125
if candidate. is_file ( ) {
126
126
// PATH may have a component like "." in it, so we still need to
127
127
// canonicalize.
128
- // Only do so if there are relative path components, otherwise symlinks to 'echo' may be resolved to their
129
- // root program like 'coreutils' which relies on the executable name for proper function.
128
+ // Only do so if there are relative path components
130
129
let has_relative_path_components = candidate. components ( ) . any ( |c| {
131
130
matches ! (
132
131
c,
133
132
std:: path:: Component :: ParentDir | std:: path:: Component :: CurDir
134
133
)
135
134
} ) ;
136
135
return Ok ( if has_relative_path_components {
137
- candidate. canonicalize ( ) ?
136
+ // Assure symlinks to programs like 'echo' don't change the file-name after resolution.
137
+ // root program like 'coreutils' which relies on the executable name for proper function.
138
+ let file_name = candidate
139
+ . file_name ( )
140
+ . expect ( "executables have a file name" )
141
+ . to_owned ( ) ;
142
+ let candidate = candidate
143
+ . canonicalize ( ) ?
144
+ . parent ( )
145
+ . expect ( "a parent is always available for tools called in test-suite" )
146
+ . join ( file_name)
147
+ . to_owned ( ) ;
148
+ if !candidate. is_file ( ) {
149
+ continue ;
150
+ }
151
+ candidate
138
152
} else {
139
153
candidate
140
154
} ) ;
You can’t perform that action at this time.
0 commit comments