Skip to content

Commit

Permalink
Do not try another config file if dir of args[0] is current dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Dec 19, 2012
1 parent 3124356 commit a8c185f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/shadowsocks-local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ func main() {
flag.Parse()

exists, err := isFileExists(configFile)
// if no config file in current directory, search it in the binary directory
if !exists || err != nil {
baseDir := path.Dir(os.Args[0])
// If no config file in current directory, try search it in the binary directory
// Note there's no portable way to detect the binary directory.
binDir := path.Dir(os.Args[0])
if (!exists || err != nil) && binDir != "" && binDir != "." {
oldConfig := configFile
configFile = path.Join(baseDir, "config.json")
configFile = path.Join(binDir, "config.json")
log.Printf("%s not found, try config file %s\n", oldConfig, configFile)
}

Expand Down

0 comments on commit a8c185f

Please sign in to comment.