fix: trim spaces in cd func

pull/21/head^2
TorchedSammy 2021-03-31 13:46:49 -04:00
parent 204d50d73c
commit b1f2a36639
1 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package fs
import ( import (
"os" "os"
"strings"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
) )
@ -26,7 +27,7 @@ var exports = map[string]lua.LGFunction{
func cd(L *lua.LState) int { func cd(L *lua.LState) int {
path := L.ToString(1) path := L.ToString(1)
err := os.Chdir(path) err := os.Chdir(strings.TrimSpace(path))
if err != nil { if err != nil {
switch err.(*os.PathError).Err.Error() { switch err.(*os.PathError).Err.Error() {
case "no such file or directory": case "no such file or directory":