mirror of
https://github.com/tjboldt/Apple2-IO-RPi.git
synced 2024-11-22 02:30:46 +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 debug bool = false
|
||||||
|
|
||||||
|
var workingDirectory string = "/home"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
host.Init()
|
host.Init()
|
||||||
|
|
||||||
@ -132,7 +134,18 @@ func handleExecCommand() {
|
|||||||
fmt.Printf("Reading command to execute...\n")
|
fmt.Printf("Reading command to execute...\n")
|
||||||
linuxCommand, err := readString()
|
linuxCommand, err := readString()
|
||||||
fmt.Printf("Command to run: %s\n", linuxCommand)
|
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 := exec.Command("bash", "-c", linuxCommand)
|
||||||
|
cmd.Dir = workingDirectory
|
||||||
cmdOut, err := cmd.Output()
|
cmdOut, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to execute command\n")
|
fmt.Printf("Failed to execute command\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user