Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
boilr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
boilr
Commits
90836f9a
Commit
90836f9a
authored
9 years ago
by
Tamer Tas
Browse files
Options
Downloads
Patches
Plain Diff
Use system calls to get the user home dir
parent
04e56be2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/cmd/bash_completion.go
+10
-9
10 additions, 9 deletions
pkg/cmd/bash_completion.go
pkg/util/osutil/user.go
+1
-1
1 addition, 1 deletion
pkg/util/osutil/user.go
with
11 additions
and
10 deletions
pkg/cmd/bash_completion.go
+
10
−
9
View file @
90836f9a
package
cmd
package
cmd
import
(
import
(
"errors"
"fmt"
"fmt"
"os"
"os"
"path/filepath"
"path/filepath"
...
@@ -9,33 +8,35 @@ import (
...
@@ -9,33 +8,35 @@ import (
cli
"github.com/spf13/cobra"
cli
"github.com/spf13/cobra"
"github.com/tmrts/boilr/pkg/boilr"
"github.com/tmrts/boilr/pkg/boilr"
"github.com/tmrts/boilr/pkg/util/exit"
"github.com/tmrts/boilr/pkg/util/exit"
"github.com/tmrts/boilr/pkg/util/osutil"
)
)
func
configureBashCompletion
()
error
{
func
configureBashCompletion
()
error
{
bash
_c
ompletion
_f
ile
:=
filepath
.
Join
(
boilr
.
Configuration
.
ConfigDirPath
,
"completion.bash"
)
bash
C
ompletion
F
ile
Path
:=
filepath
.
Join
(
boilr
.
Configuration
.
ConfigDirPath
,
"completion.bash"
)
if
err
:=
Root
.
GenBashCompletionFile
(
bash
_c
ompletion
_f
ile
);
err
!=
nil
{
if
err
:=
Root
.
GenBashCompletionFile
(
bash
C
ompletion
F
ile
Path
);
err
!=
nil
{
return
err
return
err
}
}
if
err
:=
Root
.
GenBashCompletionFile
(
bash
_c
ompletion
_f
ile
);
err
!=
nil
{
if
err
:=
Root
.
GenBashCompletionFile
(
bash
C
ompletion
F
ile
Path
);
err
!=
nil
{
return
err
return
err
}
}
bashrcPath
:=
filepath
.
Join
(
os
.
Getenv
(
"HOME"
),
".bashrc"
)
homeDir
,
err
:=
osutil
.
GetUserHomeDir
(
)
if
bashrcPath
==
""
{
if
err
!=
nil
{
return
err
ors
.
New
(
"environment variable ${HOME} should be set"
)
return
err
}
}
bashrcPath
:=
filepath
.
Join
(
homeDir
,
".bashrc"
)
f
,
err
:=
os
.
OpenFile
(
bashrcPath
,
os
.
O_APPEND
|
os
.
O_WRONLY
,
0600
)
f
,
err
:=
os
.
OpenFile
(
bashrcPath
,
os
.
O_APPEND
|
os
.
O_WRONLY
,
0600
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
defer
f
.
Close
()
defer
f
.
Close
()
bashrcText
:=
`
bashrcText
:=
`
# Enables
shell
command completion for boilr
# Enables command
-line
completion for boilr
source %s
source %s
`
`
...
...
This diff is collapsed.
Click to expand it.
pkg/util/osutil/user.go
+
1
−
1
View file @
90836f9a
...
@@ -9,5 +9,5 @@ func GetUserHomeDir() (string, error) {
...
@@ -9,5 +9,5 @@ func GetUserHomeDir() (string, error) {
return
""
,
err
return
""
,
err
}
}
return
usr
.
HomeDir
,
err
return
usr
.
HomeDir
,
nil
}
}
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