@@ -174,50 +174,34 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> ConfigPaths {
174
174
175
175
if !done {
176
176
// The next check is that we are in a reloctable directory tree
177
- let installed_suffix = Path :: new ( "/bin/fish" ) ;
178
- let just_a_fish = Path :: new ( "/fish" ) ;
179
- let suffix = if exec_path. ends_with ( installed_suffix) {
180
- Some ( installed_suffix)
181
- } else if exec_path. ends_with ( just_a_fish) {
177
+ if exec_path. ends_with ( "bin/fish" ) {
178
+ let base_path = exec_path. parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
179
+ paths = ConfigPaths {
180
+ data : base_path. join ( "share/fish" ) ,
181
+ sysconf : base_path. join ( "etc/fish" ) ,
182
+ doc : base_path. join ( "share/doc/fish" ) ,
183
+ bin : base_path. join ( "bin" ) ,
184
+ }
185
+ } else if exec_path. ends_with ( "fish" ) {
182
186
FLOG ! (
183
187
config,
184
188
"'fish' not in a 'bin/', trying paths relative to source tree"
185
189
) ;
186
- Some ( just_a_fish)
187
- } else {
188
- None
189
- } ;
190
-
191
- if let Some ( suffix) = suffix {
192
- let seems_installed = suffix == installed_suffix;
193
-
194
- let mut base_path = exec_path;
195
- base_path. shrink_to ( base_path. as_os_str ( ) . len ( ) - suffix. as_os_str ( ) . len ( ) ) ;
196
- let base_path = base_path;
197
-
198
- paths = if seems_installed {
199
- ConfigPaths {
200
- data : base_path. join ( "share/fish" ) ,
201
- sysconf : base_path. join ( "etc/fish" ) ,
202
- doc : base_path. join ( "share/doc/fish" ) ,
203
- bin : base_path. join ( "bin" ) ,
204
- }
205
- } else {
206
- ConfigPaths {
207
- data : base_path. join ( "share" ) ,
208
- sysconf : base_path. join ( "etc" ) ,
209
- doc : base_path. join ( "user_doc/html" ) ,
210
- bin : base_path,
211
- }
212
- } ;
190
+ let base_path = exec_path. parent ( ) . unwrap ( ) ;
191
+ paths = ConfigPaths {
192
+ data : base_path. join ( "share" ) ,
193
+ sysconf : base_path. join ( "etc" ) ,
194
+ doc : base_path. join ( "user_doc/html" ) ,
195
+ bin : base_path. to_path_buf ( ) ,
196
+ }
197
+ }
213
198
214
- if paths. data . exists ( ) && paths. sysconf . exists ( ) {
215
- // The docs dir may not exist; in that case fall back to the compiled in path.
216
- if !paths. doc . exists ( ) {
217
- paths. doc = PathBuf :: from ( DOC_DIR ) ;
218
- }
219
- done = true ;
199
+ if paths. data . exists ( ) && paths. sysconf . exists ( ) {
200
+ // The docs dir may not exist; in that case fall back to the compiled in path.
201
+ if !paths. doc . exists ( ) {
202
+ paths. doc = PathBuf :: from ( DOC_DIR ) ;
220
203
}
204
+ done = true ;
221
205
}
222
206
}
223
207
}
0 commit comments