Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
eae11919
Commit
eae11919
authored
Aug 06, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/utils: fix path expansion on windows
parent
78b101e1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
10 deletions
+4
-10
customflags.go
cmd/utils/customflags.go
+3
-6
customflags_test.go
cmd/utils/customflags_test.go
+1
-4
No files found.
cmd/utils/customflags.go
View file @
eae11919
...
...
@@ -21,7 +21,7 @@ import (
"fmt"
"os"
"os/user"
"path
/filepath
"
"path"
"strings"
"github.com/codegangsta/cli"
...
...
@@ -138,11 +138,8 @@ func (self *DirectoryFlag) Set(value string) {
func
expandPath
(
p
string
)
string
{
if
strings
.
HasPrefix
(
p
,
"~/"
)
||
strings
.
HasPrefix
(
p
,
"~
\\
"
)
{
if
user
,
err
:=
user
.
Current
();
err
==
nil
{
if
err
==
nil
{
p
=
strings
.
Replace
(
p
,
"~"
,
user
.
HomeDir
,
1
)
p
=
user
.
HomeDir
+
p
[
1
:
]
}
}
}
return
filepath
.
Clean
(
os
.
ExpandEnv
(
p
))
return
path
.
Clean
(
os
.
ExpandEnv
(
p
))
}
cmd/utils/customflags_test.go
View file @
eae11919
...
...
@@ -23,18 +23,15 @@ import (
)
func
TestPathExpansion
(
t
*
testing
.
T
)
{
user
,
_
:=
user
.
Current
()
tests
:=
map
[
string
]
string
{
"/home/someuser/tmp"
:
"/home/someuser/tmp"
,
"~/tmp"
:
user
.
HomeDir
+
"/tmp"
,
"~thisOtherUser/b/"
:
"~thisOtherUser/b"
,
"$DDDXXX/a/b"
:
"/tmp/a/b"
,
"/a/b/"
:
"/a/b"
,
}
os
.
Setenv
(
"DDDXXX"
,
"/tmp"
)
for
test
,
expected
:=
range
tests
{
got
:=
expandPath
(
test
)
if
got
!=
expected
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment