Jaovitosr / Jaovitosr/Chatbot

"Open terminal here" working directory ignored (gnome-terminal)

Open
#6 1 comment 0 reactions 0 assignees View on GitHub
bug cli good first issue os: linux
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

From jabref created by [credmond](https://github.com/credmond): JabRef/jabref#9953

### JabRef version

5.9 (latest release)

### Operating system

GNU / Linux

### Details on version and operating system

Linux xxx-XPS-13-9360 5.19.0-42-generic #43~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 21 16:51:08 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

### Checked with the latest development build

- [X] I made a backup of my libraries before testing the latest development version.
- [X] I have tested the latest development version and the problem persists

### Steps to reproduce the behaviour

1. Perform an "Open terminal here" on Linux
2. Note the working directory is not that of a library; it's your home directory

### Bug
Look at org.jabref.gui.desktop.os.Linux, and note:

```
String[] cmd;
if (emulatorName.contains("gnome")) {
cmd = new String[] {"gnome-terminal", "--working-directory=", absolutePath};
} else if (emulatorName.contains("xfce4")) {
cmd = new String[] {"xfce4-terminal", "--working-directory=", absolutePath};
} else if (emulatorName.contains("konsole")) {
cmd = new String[] {"konsole", "--workdir=", absolutePath};
} else {
cmd = new String[] {emulatorName, absolutePath};
}

ProcessBuilder builder = new ProcessBuilder(cmd);
```
The problem is absolutePath (which is toString()'d) is handed is as an **extra** parameter, which leads to an unexpected version of the desired command.

It's hard to see this from Java debugging because if you dive right in and look at the byte array handed to the native method call ProcessImpl.forkAndExec() -- in your IDE for example -- it will look correct...e.g., "--working-directory=/whatever", because that's String's interpretation of it. But really, there's a 0 byte element in that array after the "=", which some native downstream code interprets as meaning "what's next is another parameter", and not a concatenation to the "=".

So what's really executed is this incorrect command:

`gnome-terminal --working-directory= /whatever
`

Note the white-space. Very easy to reproduce this.

### Fix
The fix is easy, do one of the following (obviously for the other shells too if applicable):

`cmd = new String[] {"gnome-terminal", "--working-directory=" + absolutePath}; // concatonation, just one parameter
`

or...

`cmd = new String[] {"gnome-terminal", "--working-directory", absolutePath}; // also accepted by gnome-terminal, no equals
`

### Appendix

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in org.jabref.gui.desktop.os.Linux and inspect how ProcessBuilder receives the gnome-terminal, xfce4-terminal, and konsole arguments. Reproduce “Open terminal here” on Linux, verify the selected library directory is passed as intended, and confirm each supported terminal opens in that directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, linux, ubuntu
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.