Skip to content

Commit 900d6e8

Browse files
committed
Fix index out of range with os.Args
1 parent b552f1d commit 900d6e8

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ import (
88

99
func main() {
1010
var nogit bool = false
11-
if os.Args[1] == "nogit" {
12-
nogit = true
13-
fmt.Println("Ok, won't backup to git. Will still move exported files to GitRepoFolder.")
11+
12+
// Check if any args have been set
13+
if len(os.Args) > 1 {
14+
if os.Args[1] == "nogit" {
15+
nogit = true
16+
fmt.Println("Ok, won't backup to git. Will still move exported files to GitRepoFolder.")
17+
} else {
18+
fmt.Println("The only supported arg is 'nogit'")
19+
os.Exit(1)
20+
}
1421
}
1522

1623
// Get settings from settings.json

0 commit comments

Comments
 (0)