quote file variables on windows

This commit is contained in:
Gokcehan committed 2019-03-17 20:16:19 +03:00
1 parent 0eedb71d6c
commit 6f35abb4ca
3 files changed
+40 -14

No files matched your search

+4 -13
View File
@@ -283,23 +283,14 @@ func (app *app) loop() {
}
func (app *app) exportFiles() {
var envFile string
var currFile string
if f, err := app.nav.currFile(); err == nil {
envFile = f.path
currFile = f.path
}
selections := app.nav.currSelections()
currSelections := app.nav.currSelections()
envFiles := strings.Join(selections, gOpts.filesep)
os.Setenv("f", envFile)
os.Setenv("fs", envFiles)
if len(selections) == 0 {
os.Setenv("fx", envFile)
} else {
os.Setenv("fx", envFiles)
}
exportFiles(currFile, currSelections)
}
func waitKey() error {
+15
View File
@@ -10,6 +10,7 @@ import (
"os/user"
"path/filepath"
"runtime"
"strings"
)
var (
@@ -133,3 +134,17 @@ func moveCursor(y, x int) {
func isExecutable(f os.FileInfo) bool {
return f.Mode()&0111 != 0
}
func exportFiles(f string, fs []string) {
envFile := f
envFiles := strings.Join(fs, gOpts.filesep)
os.Setenv("f", envFile)
os.Setenv("fs", envFiles)
if len(fs) == 0 {
os.Setenv("fx", envFile)
} else {
os.Setenv("fx", envFiles)
}
}
+21 -1
View File
@@ -1,6 +1,7 @@
package main
import (
"fmt"
"log"
"os"
"os/exec"
@@ -36,7 +37,7 @@ var (
func init() {
if envOpener == "" {
envOpener = "start"
envOpener = `start ""`
}
if envEditor == "" {
@@ -116,3 +117,22 @@ func isExecutable(f os.FileInfo) bool {
}
return false
}
func exportFiles(f string, fs []string) {
envFile := fmt.Sprintf(`"%s"`, f)
var quotedFiles []string
for _, f := range fs {
quotedFiles = append(quotedFiles, fmt.Sprintf(`"%s"`, f))
}
envFiles := strings.Join(quotedFiles, gOpts.filesep)
os.Setenv("f", envFile)
os.Setenv("fs", envFiles)
if len(fs) == 0 {
os.Setenv("fx", envFile)
} else {
os.Setenv("fx", envFiles)
}
}