Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug:t.SetStartDir() is not working #76

Open
EthonWang opened this issue Apr 26, 2024 · 3 comments
Open

bug:t.SetStartDir() is not working #76

EthonWang opened this issue Apr 26, 2024 · 3 comments

Comments

@EthonWang
Copy link

When I use “fyne-io/terminal” in a Windows environment, I want to use t.SetStartDir() to set the initial directory, but I found that it's not working.

I discovered that a line of code is missing in the term_window.go file to apply the t.SetStartDir() .

I add os.Chdir(t.startingDir()) in method startPTY().

It worked:
image

@Jacalz
Copy link
Member

Jacalz commented Apr 26, 2024

I think that changes the current directory of the whole application binary? That will likely have negative effects on any other code that uses PWD for path lookups.

@EthonWang
Copy link
Author

EthonWang commented Apr 27, 2024

I think that changes the current directory of the whole application binary? That will likely have negative effects on any other code that uses PWD for path lookups.

You're right to think about it.

My requirement is that when the terminal is opened, the starting directory is the directory I specify, not the location of the program itself.

For example: when run test.exe, by default, the starting directory of the terminal is the location of the program, such as e://apps/test.exe.

Fyne-io/terminal provides a method to specify the initial directory:

// SetStartDir can be called before one of the Run calls to specify the initial directory.
func (t *Terminal) SetStartDir(path string) {
	t.startDir = path
}

This method is very useful for me. But it didn't work (see above).

In my application requirements, I need to open different terminal Windows. The start directory for each terminal is loaded from the configuration file, rather than requiring a manual cd replacement, which is more convenient.

@Jacalz
Copy link
Member

Jacalz commented Apr 27, 2024

Yes, absolutely. I'm just saying that I think there should be a better fix that doesn't have the negative effects discussed above (I'm not a Windows user though so can't help with that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants