mirror of https://github.com/Hilbis/Hilbish
refactor: panic in history.go for more context
parent
23902ea25c
commit
0e4f552be2
|
@ -12,11 +12,11 @@ type fileHistory struct {
|
|||
f *os.File
|
||||
}
|
||||
|
||||
func newFileHistory() (*fileHistory, error) {
|
||||
func newFileHistory() *fileHistory {
|
||||
data, err := os.ReadFile(defaultHistPath)
|
||||
if err != nil {
|
||||
if !errors.Is(err, fs.ErrNotExist) {
|
||||
return nil, err
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func newFileHistory() (*fileHistory, error) {
|
|||
}
|
||||
f, err := os.OpenFile(defaultHistPath, os.O_APPEND | os.O_WRONLY | os.O_CREATE, 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fh := &fileHistory{
|
||||
|
@ -38,7 +38,7 @@ func newFileHistory() (*fileHistory, error) {
|
|||
f: f,
|
||||
}
|
||||
|
||||
return fh, nil
|
||||
return fh
|
||||
}
|
||||
|
||||
func (h *fileHistory) Write(line string) (int, error) {
|
||||
|
|
6
rl.go
6
rl.go
|
@ -20,11 +20,7 @@ func newLineReader(prompt string, noHist bool) *lineReader {
|
|||
// we don't mind hilbish.read rl instances having completion,
|
||||
// but it cant have shared history
|
||||
if !noHist {
|
||||
fh, err := newFileHistory()
|
||||
fileHist = fh // go stupid
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fileHist = newFileHistory()
|
||||
rl.SetHistoryCtrlR("file", fileHist)
|
||||
rl.HistoryAutoWrite = false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue