added ~ as home processing

This commit is contained in:
JISAUAY committed 2025-06-27 11:23:15 -05:00
1 parent 7062e798a9
commit 9e46cc9105
7 files changed
+79 -6

No files matched your search

+33 -1
View File
@@ -43,6 +43,21 @@ func parse_flags(parts []string) (map[string]string, []string) {
return flags, args
}
func process_golshscript(sh *types.Shell, file_path string) {
data, err := os.ReadFile(file_path)
if err != nil {
fmt.Println("Error: ", err)
return
}
lines := strings.Split(string(data), "\n")
for _, line := range lines {
gosh_process_input(sh, strings.TrimSpace(line))
}
}
func check_pathes(sh *types.Shell, name string, args []string) bool {
var output types.CmdOutput
@@ -105,7 +120,11 @@ func gosh_process_input(sh *types.Shell, input string) {
}
prevOutput = cmd.GoshCd(sh, parts[1])
case "ls":
prevOutput = cmd.GoshLs(sh)
if len(parts) > 1 {
prevOutput = cmd.GoshLs(sh, parts[1:]...)
} else {
prevOutput = cmd.GoshLs(sh)
}
case "cat":
if len(parts) < 2 {
fmt.Println("Usage: cat <path to file>")
@@ -155,6 +174,19 @@ func main() {
Cd: dir,
PyPaths: []string{}}
// Check for and execute .golshrc
golshrc_path, _ := os.UserHomeDir()
golshrc_path = golshrc_path + "/.golshrc"
_, err := os.Stat(golshrc_path)
golshrc_exists := err == nil
fmt.Println(golshrc_exists)
if golshrc_exists {
fmt.Println("exists")
process_golshscript(&sh, golshrc_path)
}
var should_exit = false
for {
c.Print(sh.Cd)