kopia lustrzana
https://github.com/quitesimpleorg/hs9001.git
synced 2024-11-22 10:57:50 +01:00
add: Fix panic when history command returns nothing
If you disable bash history files alltogether, "history 1" will not contain anything on first launch of a terminal and therefore the regex has nothing to parse, so we get an out of bounds array access. So fix this. Though it's a dirty silent fail now, I don't want error messages/warnings everytime I open a shell.
This commit is contained in:
rodzic
79a26e2aa1
commit
c67d38482d
2
main.go
2
main.go
@ -140,7 +140,9 @@ func main() {
|
|||||||
historycmd := args[1]
|
historycmd := args[1]
|
||||||
var rgx = regexp.MustCompile("\\s+\\d+\\s+(.*)")
|
var rgx = regexp.MustCompile("\\s+\\d+\\s+(.*)")
|
||||||
rs := rgx.FindStringSubmatch(historycmd)
|
rs := rgx.FindStringSubmatch(historycmd)
|
||||||
|
if len(rs) == 2 {
|
||||||
add(conn, rs[1])
|
add(conn, rs[1])
|
||||||
|
}
|
||||||
} else if cmd == "search" {
|
} else if cmd == "search" {
|
||||||
if argslen < 2 {
|
if argslen < 2 {
|
||||||
fmt.Fprint(os.Stderr, "Please provide the search query\n")
|
fmt.Fprint(os.Stderr, "Please provide the search query\n")
|
||||||
|
Ładowanie…
Reference in New Issue
Block a user