import-utils.go: Paths are now expanded with respect to env-vars and shell ~
This commit is contained in:
parent
e35d4e3f70
commit
4e3f5cfbc6
@ -75,7 +75,11 @@ func isFile(filePath string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func searchAmongPath(filename string, dirList []string) (filePath string) {
|
func searchAmongPath(filename string, dirList []string) (filePath string) {
|
||||||
|
var err error
|
||||||
for _, dir := range dirList {
|
for _, dir := range dirList {
|
||||||
|
if dir, err = ExpandPath(dir); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if fullPath := path.Join(dir, filename); isFile(fullPath) {
|
if fullPath := path.Join(dir, filename); isFile(fullPath) {
|
||||||
filePath = fullPath
|
filePath = fullPath
|
||||||
break
|
break
|
||||||
@ -90,6 +94,10 @@ func isPathRelative(filePath string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeFilepath(filename string, dirList []string) (filePath string, err error) {
|
func makeFilepath(filename string, dirList []string) (filePath string, err error) {
|
||||||
|
if filename, err = ExpandPath(filename); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if path.IsAbs(filename) || isPathRelative(filename) {
|
if path.IsAbs(filename) || isPathRelative(filename) {
|
||||||
if isFile(filename) {
|
if isFile(filename) {
|
||||||
filePath = filename
|
filePath = filename
|
||||||
|
Loading…
Reference in New Issue
Block a user