mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	fix: dont copy default conf to user dir
doing this prevents problems in later releases with breaking changes (though this shouldnt be the case anymore)
This commit is contained in:
		
							parent
							
								
									f05ab921d7
								
							
						
					
					
						commit
						2a0cd1464a
					
				
							
								
								
									
										27
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								main.go
									
									
									
									
									
								
							@ -113,35 +113,30 @@ func main() {
 | 
			
		||||
		os.Setenv("SHELL", os.Args[0])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	go handleSignals()
 | 
			
		||||
	luaInit()
 | 
			
		||||
	runLogin()
 | 
			
		||||
	// If user's config doesn't exixt,
 | 
			
		||||
	if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) {
 | 
			
		||||
	if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
 | 
			
		||||
		// Read default from current directory
 | 
			
		||||
		// (this is assuming the current dir is Hilbish's git)
 | 
			
		||||
		input, err := os.ReadFile(".hilbishrc.lua")
 | 
			
		||||
		_, err := os.ReadFile(".hilbishrc.lua")
 | 
			
		||||
		confpath := ".hilbishrc.lua"
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			// If it wasnt found, go to the real sample conf
 | 
			
		||||
			input, err = os.ReadFile(sampleConfPath)
 | 
			
		||||
			_, err = os.ReadFile(sampleConfPath)
 | 
			
		||||
			confpath = sampleConfPath
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				fmt.Println("could not find .hilbishrc.lua or", sampleConfPath)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Create it using either default config we found
 | 
			
		||||
		err = os.WriteFile(defaultConfPath, input, 0644)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			// If that fails, bail
 | 
			
		||||
			fmt.Println("Error creating config file")
 | 
			
		||||
			fmt.Println(err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		runConfig(confpath)
 | 
			
		||||
	} else {
 | 
			
		||||
		runConfig(*configflag)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	go handleSignals()
 | 
			
		||||
	luaInit()
 | 
			
		||||
	runLogin()
 | 
			
		||||
	runConfig(*configflag)
 | 
			
		||||
 | 
			
		||||
	if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
 | 
			
		||||
		scanner := bufio.NewScanner(bufio.NewReader(os.Stdin))
 | 
			
		||||
		for scanner.Scan() {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user