Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:opensuse_zh
elvish
elvish-multi-dots.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File elvish-multi-dots.patch of Package elvish
Index: elvish-0.18.0/pkg/eval/eval.go =================================================================== --- elvish-0.18.0.orig/pkg/eval/eval.go +++ elvish-0.18.0/pkg/eval/eval.go @@ -298,6 +298,29 @@ func (ev *Evaler) AddBeforeExit(f func() ev.BeforeExit = append(ev.BeforeExit, f) } +// expandMultiDots expands three or more dots in path to double dots +// since golang supports double dots in path only +func expandMultiDots(path string) string { + r := []rune(path) + for i := len(r)-1; i >= 2; i-- { + if r[i] == '.' && r[i-1] == '.' && r[i-2] == '.' { + var left bool + var leftover []rune + if len(r[i+1:]) > 0 { + left = true + leftover = make([]rune, len(r[i+1:])) + copy(leftover, r[i+1:]) + } + r = append(r[:i], os.PathSeparator, '.', '.') + if left { + r = append(r, leftover...) + } + } + } + + return string(r) +} + // Chdir changes the current directory, and updates $E:PWD on success // // It runs the functions in beforeChdir immediately before changing the @@ -308,7 +331,7 @@ func (ev *Evaler) Chdir(path string) err hook(path) } - err := os.Chdir(path) + err := os.Chdir(expandMultiDots(path)) if err != nil { return err }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor