mirror of
https://github.com/tjboldt/Apple2-IO-RPi.git
synced 2024-11-25 21:33:15 +00:00
Updated driver to support working directory
This commit is contained in:
parent
a16de00a13
commit
1300d75c10
@ -50,6 +50,8 @@ const SaveFileCommand = 7
|
||||
|
||||
var debug bool = false
|
||||
|
||||
var workingDirectory string = "/home"
|
||||
|
||||
func main() {
|
||||
host.Init()
|
||||
|
||||
@ -132,7 +134,18 @@ func handleExecCommand() {
|
||||
fmt.Printf("Reading command to execute...\n")
|
||||
linuxCommand, err := readString()
|
||||
fmt.Printf("Command to run: %s\n", linuxCommand)
|
||||
if strings.HasPrefix(linuxCommand, "cd /") {
|
||||
workingDirectory = strings.Replace(linuxCommand, "cd ", "", 1)
|
||||
writeString("Working directory set")
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(linuxCommand, "cd ") {
|
||||
workingDirectory = workingDirectory + "/" + strings.Replace(linuxCommand, "cd ", "", 1)
|
||||
writeString("Working directory set")
|
||||
return
|
||||
}
|
||||
cmd := exec.Command("bash", "-c", linuxCommand)
|
||||
cmd.Dir = workingDirectory
|
||||
cmdOut, err := cmd.Output()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to execute command\n")
|
||||
|
Loading…
Reference in New Issue
Block a user