Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
028d2d88
Commit
028d2d88
authored
Jan 08, 2019
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated github.com/mitchellh/go-homedir from `b8bc1bf` to `ae18d6b`
Fix #114
parent
adad9220
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
20 deletions
+41
-20
Gopkg.lock
Gopkg.lock
+2
-2
vendor/github.com/mitchellh/go-homedir/go.mod
vendor/github.com/mitchellh/go-homedir/go.mod
+1
-0
vendor/github.com/mitchellh/go-homedir/homedir.go
vendor/github.com/mitchellh/go-homedir/homedir.go
+38
-18
No files found.
Gopkg.lock
View file @
028d2d88
...
...
@@ -219,11 +219,11 @@
[[projects]]
branch = "master"
digest = "1:
12ae6210bdbdad658a9a67fd95cd9c99f7fdbf12f6d36eaf0af704e69dacf4f5
"
digest = "1:
78bbb1ba5b7c3f2ed0ea1eab57bdd3859aec7e177811563edc41198a760b06af
"
name = "github.com/mitchellh/go-homedir"
packages = ["."]
pruneopts = "UT"
revision = "
b8bc1bf767474819792c23f32d8286a45736f1c6
"
revision = "
ae18d6b8b3205b561c79e8e5f69bff09736185f4
"
[[projects]]
branch = "master"
...
...
vendor/github.com/mitchellh/go-homedir/go.mod
0 → 100644
View file @
028d2d88
module github.com/mitchellh/go-homedir
vendor/github.com/mitchellh/go-homedir/homedir.go
View file @
028d2d88
...
...
@@ -77,33 +77,51 @@ func Expand(path string) (string, error) {
}
func
dirUnix
()
(
string
,
error
)
{
homeEnv
:=
"HOME"
if
runtime
.
GOOS
==
"plan9"
{
// On plan9, env vars are lowercase.
homeEnv
=
"home"
}
// First prefer the HOME environmental variable
if
home
:=
os
.
Getenv
(
"HOME"
);
home
!=
""
{
if
home
:=
os
.
Getenv
(
homeEnv
);
home
!=
""
{
return
home
,
nil
}
// If that fails, try getent
var
stdout
bytes
.
Buffer
cmd
:=
exec
.
Command
(
"getent"
,
"passwd"
,
strconv
.
Itoa
(
os
.
Getuid
()))
cmd
.
Stdout
=
&
stdout
if
err
:=
cmd
.
Run
();
err
!=
nil
{
// If the error is ErrNotFound, we ignore it. Otherwise, return it.
if
err
!=
exec
.
ErrNotFound
{
return
""
,
err
// If that fails, try OS specific commands
if
runtime
.
GOOS
==
"darwin"
{
cmd
:=
exec
.
Command
(
"sh"
,
"-c"
,
`dscl -q . -read /Users/"$(whoami)" NFSHomeDirectory | sed 's/^[^ ]*: //'`
)
cmd
.
Stdout
=
&
stdout
if
err
:=
cmd
.
Run
();
err
==
nil
{
result
:=
strings
.
TrimSpace
(
stdout
.
String
())
if
result
!=
""
{
return
result
,
nil
}
}
}
else
{
if
passwd
:=
strings
.
TrimSpace
(
stdout
.
String
());
passwd
!=
""
{
// username:password:uid:gid:gecos:home:shell
passwdParts
:=
strings
.
SplitN
(
passwd
,
":"
,
7
)
if
len
(
passwdParts
)
>
5
{
return
passwdParts
[
5
],
nil
cmd
:=
exec
.
Command
(
"getent"
,
"passwd"
,
strconv
.
Itoa
(
os
.
Getuid
()))
cmd
.
Stdout
=
&
stdout
if
err
:=
cmd
.
Run
();
err
!=
nil
{
// If the error is ErrNotFound, we ignore it. Otherwise, return it.
if
err
!=
exec
.
ErrNotFound
{
return
""
,
err
}
}
else
{
if
passwd
:=
strings
.
TrimSpace
(
stdout
.
String
());
passwd
!=
""
{
// username:password:uid:gid:gecos:home:shell
passwdParts
:=
strings
.
SplitN
(
passwd
,
":"
,
7
)
if
len
(
passwdParts
)
>
5
{
return
passwdParts
[
5
],
nil
}
}
}
}
// If all else fails, try the shell
stdout
.
Reset
()
cmd
=
exec
.
Command
(
"sh"
,
"-c"
,
"cd && pwd"
)
cmd
:
=
exec
.
Command
(
"sh"
,
"-c"
,
"cd && pwd"
)
cmd
.
Stdout
=
&
stdout
if
err
:=
cmd
.
Run
();
err
!=
nil
{
return
""
,
err
...
...
@@ -123,14 +141,16 @@ func dirWindows() (string, error) {
return
home
,
nil
}
// Prefer standard environment variable USERPROFILE
if
home
:=
os
.
Getenv
(
"USERPROFILE"
);
home
!=
""
{
return
home
,
nil
}
drive
:=
os
.
Getenv
(
"HOMEDRIVE"
)
path
:=
os
.
Getenv
(
"HOMEPATH"
)
home
:=
drive
+
path
if
drive
==
""
||
path
==
""
{
home
=
os
.
Getenv
(
"USERPROFILE"
)
}
if
home
==
""
{
return
""
,
errors
.
New
(
"HOMEDRIVE, HOMEPATH, and USERPROFILE are blank"
)
return
""
,
errors
.
New
(
"HOMEDRIVE, HOMEPATH, or USERPROFILE are blank"
)
}
return
home
,
nil
...
...
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