Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mshell/msh
codex.log
.gocache/
.gomodcache/
.gopath/
.cache/

*.mshell_history
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Version-sorted entries, directories first and colored blue
- Binary file detection for preview
- Preview caching for fast scrolling
- Cut/copy/paste buffer (`d` cut, `yy` copy, `p` paste, `c` clear) shared across instances
- Delete to trash (`x`) with confirmation, using platform-native trash
- `msh fm` prints final directory to stdout for `cd "$(msh fm)"` usage

## 0.10.0 - 2026-02-13
Expand Down
44 changes: 36 additions & 8 deletions mshell/Evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7146,26 +7146,54 @@ func (state *EvalState) RunPipeline(MShellPipe MShellPipe, context ExecuteContex
}

func CopyFile(source string, dest string) error {
// TODO: Fix this dumb copy code.
// Copy the file
input, err := os.Open(source)
srcInfo, err := os.Lstat(source)
if err != nil {
return err
}
defer input.Close()

output, err := os.Create(dest)
// Handle symlinks
if srcInfo.Mode()&os.ModeSymlink != 0 {
target, err := os.Readlink(source)
if err != nil {
return err
}
return os.Symlink(target, dest)
}

// Handle directories recursively
if srcInfo.IsDir() {
if err := os.MkdirAll(dest, srcInfo.Mode().Perm()); err != nil {
return err
}
entries, err := os.ReadDir(source)
if err != nil {
return err
}
for _, entry := range entries {
srcPath := filepath.Join(source, entry.Name())
dstPath := filepath.Join(dest, entry.Name())
if err := CopyFile(srcPath, dstPath); err != nil {
return err
}
}
return nil
}

// Regular file: preserve permissions
input, err := os.Open(source)
if err != nil {
return err
}
defer output.Close()
defer input.Close()

_, err = io.Copy(output, input)
output, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, srcInfo.Mode().Perm())
if err != nil {
return err
}
defer output.Close()

return nil
_, err = io.Copy(output, input)
return err
}

func VersionSortComparer(a_str string, b_str string) int {
Expand Down
Loading