Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
ion
Commits
ba3c9d7a
Commit
ba3c9d7a
authored
7 years ago
by
Forb.Jok
Browse files
Options
Downloads
Patches
Plain Diff
Fix cd'ing into a symlinked directory losing the original path
parent
6acfc6eb
No related branches found
No related tags found
1 merge request
!689
Fix cd'ing into a symlinked directory losing the original path
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/shell/directory_stack.rs
+26
-9
26 additions, 9 deletions
src/lib/shell/directory_stack.rs
with
26 additions
and
9 deletions
src/lib/shell/directory_stack.rs
+
26
−
9
View file @
ba3c9d7a
...
...
@@ -235,18 +235,35 @@ impl DirectoryStack {
dir
:
&
str
,
variables
:
&
Variables
,
)
->
Result
<
(),
Cow
<
'static
,
str
>>
{
match
(
set_current_dir
(
dir
),
current_dir
())
{
(
Ok
(()),
Ok
(
cur_dir
))
=>
{
self
.push_dir
(
cur_dir
,
variables
);
use
std
::
path
::{
Component
,
Path
};
// Create a clone of the current directory.
let
mut
new_dir
=
match
self
.dirs
.front
()
{
Some
(
cur_dir
)
=>
cur_dir
.clone
(),
None
=>
PathBuf
::
new
()
};
// Iterate through components of the specified directory
// and calculate the new path based on them.
for
component
in
Path
::
new
(
dir
)
.components
()
{
match
component
{
Component
::
CurDir
=>
{
},
Component
::
ParentDir
=>
{
new_dir
.pop
();
},
_
=>
{
new_dir
.push
(
component
);
}
};
}
// Try to change into the new directory
match
set_current_dir
(
&
new_dir
)
{
Ok
(())
=>
{
// Push the new current directory onto the directory stack.
self
.push_dir
(
new_dir
,
variables
);
Ok
(())
}
(
Err
(
err
)
,
_
)
=>
Err
(
Cow
::
Owned
(
format!
(
Err
(
err
)
=>
Err
(
Cow
::
Owned
(
format!
(
"ion: failed to set current dir to {}: {}
\n
"
,
dir
,
err
))),
(
..
)
=>
Err
(
Cow
::
Borrowed
(
"ion: change_and_push_dir(): error occurred that should never happen
\n
"
,
)),
// This should not happen
new_dir
.to_string_lossy
(),
err
)))
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment