Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 5717

Summary: [Import/Export] Linux export dialog doesn't expand tilde (~) to home directory
Product: [Eclipse Project] Platform Reporter: Patrick Dubroy <Patrick_Dubroy>
Component: IDEAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P5 CC: airvine, b.muskalla, billy.biggs, denis.roy, douglas.pollock, eclipse, fredrik.attebrant, johan.walles, Kevin_McGuire, maxime_daniel
Version: 2.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug
Bug Depends on: 22643    
Bug Blocks: 284163    
Attachments:
Description Flags
Screenshot of Gimp preferences none

Description Patrick Dubroy CLA 2001-11-09 13:02:40 EST
On Linux (as on Windows) the export dialog has a combo box with a browse button 
beside it to input or select the export destination. On most Unix/Linux apps 
you can enter a path such as ~/foo.zip, where "~" will expand to your home 
directory. eg. ~/foo.zip might expand to /home/pdubroy/foo.zip. Eclipse will 
instead try to make a directory named "~" in the current working directory, 
which is then very difficult to delete or traverse into in the shell.
Comment 1 Patrick Dubroy CLA 2001-11-09 13:58:52 EST
build 20011106
Comment 2 Kevin Haaland CLA 2001-11-12 13:23:29 EST
DirectoryDialog is supplied by SWT. Moving to SWT for comment.
Comment 3 Patrick Dubroy CLA 2001-11-14 17:44:55 EST
This does not refer to the DirectoryDialog. To clarify, the problem is with the 
combo labelled "Directory:", not the dialog that appears when you hit the 
browse button.

Typing a directory such as "~/eclipse/dev/eclipse/jre/bin" into the combo, 
INSTEAD of browsing to the directory, is what causes the problem.

Sorry for the confusion. Moving back to UI.
Comment 4 Tod Creasey CLA 2001-12-12 15:58:59 EST
This is platform behaviour. If you execute the following code:


import java.io.*;

public class FileTest {
	
	public static void main(String[] args){
		try{
		File file = new File("~");
		file.mkdirs();
		
		File child = new File(file,"bob.txt");
		FileOutputStream stream = new FileOutputStream(child);
		stream.write('c');
		stream.write('d');
		stream.write('e');
		stream.write('f');
		stream.close();

		
		}
		catch (IOException exception){
			exception.printStackTrace();
	};
	}

}

you will get a directory called ~ in your eclipse directory with a file called 
bob.txt in it. ~ is a command that the shell offers but it is not a reserved 
character in Linux - i.e. it is a valid name for a directory.

I concur that this is confusing however but I am not sure what Eclipse should 
do about it.
Comment 5 Tod Creasey CLA 2001-12-12 16:51:31 EST
Platform behaviour. Closing.
Comment 6 Johan Walles CLA 2001-12-13 02:26:40 EST
Please re-open.  On Unix platforms ~ means "home directory".  Why do you think
having this behaviour implemented in all shells (or please provide a
counter-example) is contradictory to having Eclipse implement it?
Comment 7 Kevin Haaland CLA 2001-12-13 09:12:25 EST
Johan,

We do not have the cycles to look at this problem right now. Since it is 
obvious that you really care about solving this problem I encourage you to 
write the code and submit a patch. 

If you are interested, let me know through the developer's mailing list; and I 
will help set you up with a self hosting environment. 
Comment 8 Johan Walles CLA 2001-12-13 09:35:23 EST
That you don't want to solve this *now* is not a reason for marking this bug as
"invalid".  If it is not a high priority bug, lower its priority but don't close
it!!

What mozilla.org does in their bugzilla is that they have a a "helpwanted"
status keyword for bugs they don't want to solve themselves.  Then they put
"nobody@mozilla.org" as responsible for the bugs and leave them in the Bugzilla.
 You should probably treat this bug the same way.

I am not too sure I can find the time to look at this.  If I do, I'll be sure to
let you know.

Please re-open.
Comment 9 Kevin Haaland CLA 2001-12-13 11:11:29 EST
Your suggestion for a help wanted status is interesting. Let me think about it 
some more until then I will lower the priority and change the resolution to 
LATER. 
Comment 10 Kevin Haaland CLA 2001-12-13 11:11:52 EST
No cycles to deal with this feature request now. 
Comment 11 Patrick Dubroy CLA 2001-12-13 11:55:18 EST
I realize that "~" is a valid name for a file but as Johan pointed out, every 
shell in the known universe treats it as a special character, and consequently 
so do file selection dialogs. Eclipse is *wrong* to ignore this.

I believe that this is not a feature request but a bug. I'm not sure that 
marking it as RESOLVED is the correct thing to do.
Comment 12 Randy Giffen CLA 2002-08-08 17:01:38 EDT
Reopen for investigation
Comment 13 Patrick Dubroy CLA 2002-08-27 14:26:16 EDT
Andrew asked me if I knew of some apps that could be used as a reference, and I 
found out some interesting things:

- the KDE file selection dialog will do something similar to Eclipse -- if you 
use ~ in the path it treats it as a directory, eg. /home/pdubroy/~/foo
- GNOME file selection dialog does The Right Thing (TM) and expands it to your 
home directory, and does the same for ~someuser.
- Netscape replaces ~ with your home directory as soon as you type it. ie., I 
type ~ and it is immediately expanded to "/home/pdubroy", so typing ~/foo.c 
will give me what I expect: /home/pdubroy/foo.c. There is no support for 
~someuser.
- Mozilla is like Netscape in that it supports only plain ~, but it doesn't do 
the automatic expansion thing.

So Andrew: I can't find any small app that does this on its own. Most people 
use either the Motif, Qt, or GTK file dialogs. You could try looking at these.

I don't think it's bad if Eclipse doesn't do the ~user thing, so the easiest 
thing is probably to just check for "~/" at the beginning, and if it exists, 
replace it with the contents of $HOME.
Comment 14 Billy Biggs CLA 2005-01-05 17:07:34 EST
I intend to add support for ~/ but not ~username.
Comment 15 Billy Biggs CLA 2005-10-11 06:41:26 EDT
*** Bug 112181 has been marked as a duplicate of this bug. ***
Comment 16 Benjamin Muskalla CLA 2006-07-25 05:18:41 EDT
I wonder if this enhancement should be an Platform/UI problem or since 3.2, a thing we could get into EFS. I think it's worth to add this to the EFS Local implementation for Linux to get the ~ working for all operations and not only for Import/Export
Comment 17 John Arthorne CLA 2007-01-29 09:53:25 EST
See related bug 169385
Comment 18 Susan McCourt CLA 2009-07-15 12:10:09 EDT
"As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009"
Comment 19 Szymon Brandys CLA 2009-07-31 04:51:46 EDT
There is a similar issue in team stuff. Are we going to resolve ~ into home directory in location fields?
Comment 20 Prakash Rangaraj CLA 2009-07-31 05:17:12 EDT
(In reply to comment #19)
> There is a similar issue in team stuff. Are we going to resolve ~ into home
> directory in location fields?

    as Tod mentioned in Comment #4, its not supported by Java - just the shells. When I do cd ~ and then hit tab, I'm getting many options (I'm on a Mac) Is the ~ char some sort of standard or just a convention followed by the shells?
Comment 21 Szymon Brandys CLA 2009-07-31 07:24:55 EDT
It's not supported by java, however Eclipse could provide such a thing. Personally I can go either way, however since there are user requests for supporting ~ I asked UI for a comment. If UI says we don't want to do this I will follow and users would have to live with it.

I think that ~ is just a convention.

The reason why I'm picking it up is bug 284163. I would like to either fix it or close it. BTW this bug looks like it WONT be FIXed ;)
Comment 22 Prakash Rangaraj CLA 2009-07-31 07:40:00 EDT
(In reply to comment #21)
> The reason why I'm picking it up is bug 284163. I would like to either fix it
> or close it. BTW this bug looks like it WONT be FIXed ;)

     If most of the other apps support this, then we must also support this. I wouldn't mark this as wont-fix. Its just the priority of this is low compared to the other bugs we have :-) 
Comment 23 Szymon Brandys CLA 2009-07-31 08:07:07 EDT
(In reply to comment #22)
> If most of the other apps support this, then we must also support this. I
> wouldn't mark this as wont-fix. Its just the priority of this is low compared to
> the other bugs we have :-)

As Denis states in bug 284163, comment 3 GUI apps support this, so we should probably do the same.
Comment 24 Paul Webster CLA 2009-07-31 08:12:09 EDT
(In reply to comment #22)
>      If most of the other apps support this, then we must also support this. I
> wouldn't mark this as wont-fix. Its just the priority of this is low compared
> to the other bugs we have :-) 

Which other apps have this so we can compare?  I wasn't able to find any with:
Label: <field> [Browse]

It works if you use the Browse button in eclipse (because it's the native file dialog).

Gedit only opens the native file dialog (so we're compatible).  Firefox also opens the native dialog for CTRL+O, but if you type any combination with a ~ into the URL field it fails.  Gimp doesn't allow ~ in it's preference fields for folders, but picks it up from the native file dialog as well.

It's not enough that "some" apps support this.  Firefox and Gimp are major apps, and they don't.


PW
Comment 25 Szymon Brandys CLA 2009-07-31 08:39:52 EDT
Adding Denis who is interested in this fix and can answer the Paul's question. 
Comment 26 Denis Roy CLA 2009-07-31 09:53:51 EDT
Created attachment 143140 [details]
Screenshot of Gimp preferences

(In reply to comment #24)
> Firefox also
> opens the native dialog for CTRL+O, but if you type any combination with a ~
> into the URL field it fails.  Gimp doesn't allow ~ in it's preference fields
> for folders, but picks it up from the native file dialog as well.

Hmmm, on both Fedora 11 and Kubuntu, I can use the tilde in any File operation in Firefox (CTRL+O, CTRL+S, etc).  Even in the preferences, I can use the tilde for file locations.  Of course, it doesn't work in the location bar, but I expected that from a URI field.

Same with Gimp -- all the file operations, including Preferences > Folders use the native file dialogs, so I can use the tilde.  In the case of Preferences, the native dialog is opened by hitting 'other...' from the short drop-down list.

Ironically, I used ~/crud/tilde.jpg in the Gimp Save As dialog, and then again in the Firefox Browse for this here file attachment.

As I said in the other bug, I use lots of Linux distros, and for me it's easier to use the keyboard and ~ rather than clickety-click my file browser dialogs -- and Eclipse is consistently screwing me up  :)
Comment 27 Paul Webster CLA 2009-07-31 10:04:00 EDT
(In reply to comment #26)
> Created an attachment (id=143140) [details]
> Screenshot of Gimp preferences
> 
> (In reply to comment #24)
> > Firefox also
> > opens the native dialog for CTRL+O, but if you type any combination with a ~
> > into the URL field it fails.  Gimp doesn't allow ~ in it's preference fields
> > for folders, but picks it up from the native file dialog as well.
> 
> Hmmm, on both Fedora 11 and Kubuntu, I can use the tilde in any File operation
> in Firefox (CTRL+O, CTRL+S, etc).  Even in the preferences, I can use the tilde
> for file locations.

Right, ~ works fine in the native dialog (the same as it does in eclipse).

I couldn't find anywhere in firefox to enter a file location without using a browser button (which opens the file dialog which does accept ~).


> Same with Gimp -- all the file operations, including Preferences > Folders use
> the native file dialogs, so I can use the tilde.  In the case of Preferences,
> the native dialog is opened by hitting 'other...' from the short drop-down
> list.

Right, my point is the native file dialog in eclipse works the same way.  Click browse, and use ~ to your heart's content.

> As I said in the other bug, I use lots of Linux distros, 

I'm still not seeing a free-form text field in the applications mentioned that accepts ~

PW
Comment 28 Paul Webster CLA 2009-07-31 10:06:27 EDT
(In reply to comment #27)
> 
> I'm still not seeing a free-form text field in the applications mentioned that
> accepts ~

Does that mean the implications for being comparable to the other native apps is that fields with Browse buttons should be read-only (forcing the user through the native file dialog as Gimp and Firefox do)?

I'm not in favour of this, just pointing out that's why these other apps work :-)

PW

Comment 29 Denis Roy CLA 2009-07-31 10:10:47 EDT
(In reply to comment #24)
> Which other apps have this so we can compare?  I wasn't able to find any with:
> Label: <field> [Browse]

Sorry, I guess I haven't had enough coffee yet.  The above statement is right: all other apps invoke the native dialog immediately, whereas the patch dialogs allow you to type text (which doesn't support the tilde) or Browse, which uses the native dialog.

Looks like Eclipse is somewhat inconsistent with other apps with its Label: <field> [Browse] setup, but in the grand scheme of things I think this is a benefit.  I'm going to close my bug 284163 as worksforme.
Comment 30 Denis Roy CLA 2009-07-31 10:18:08 EDT
(In reply to comment #28)
> I'm not in favour of this, just pointing out that's why these other apps work
> :-)

Agreed.  I think it's good to acknowledge that Eclipse is inconsistent with other apps in this respect (hence the reasons users keep trying to use tilde in the wrong field), but IMHO I think the lesser of two evils is leaving the dialog alone, instead of forcing the user to click [Browse].
Comment 31 Denis Roy CLA 2009-08-04 09:36:38 EDT
FWIW, OpenOffice doesn't seem to use the native dialogs, and it supports using the tilde.
Comment 32 Jan Sonnenberg CLA 2010-04-06 09:36:04 EDT
Found this bug searching for a solution for tilde expansion under Java on Linux. The following code solved my problem:

String directory_name = "~/";
if(directory_name.contains("~")){
   directory_name = directory_name.replace("~", System.getProperty("user.home"));
}
File directory = new File(directory_name);
if(directory.exists){
   // ...
}
Comment 33 Johan Walles CLA 2010-04-06 10:45:14 EDT
(In reply to comment #32)
> if(directory_name.contains("~")){
>    directory_name = directory_name.replace("~",
> System.getProperty("user.home"));
> }

Proper ~ expansion should do (at least) two things:
1. Expand "~" to the current user's home directory.  Your code does that.
2. Expand "~username" to user username's home directory.  Your code doesn't do that.

That said, I think typing just "~" is an infinitely more common use case.  And supporting just "~" would be a lot better than trying to create directories named "~".

I just tried the export dialog btw, which this bug is about (read the description), and:
* The browse button now brings up a file dialog that actually does seem to expand "~" properly.
* The file dialog also seems to expand "~username" properly.
* If I just type "~/monkey.jar" in the text field, Eclipse still tries to create a ~ directory in my workspace.

So the dialog works, but the text box is still broken.
Comment 34 Fredrik Attebrant CLA 2011-01-05 03:42:51 EST
Same problem also applies to MacOSX (10.6.5). 
Ran into this on Eclipse 3.6.1.

I've hit this (not being able to use ~ or ~user) in import/export dialogs.

Also noted that "~" and "~user" is supported natively by MacOSX in Finder and other apps.
Comment 35 Lars Vogel CLA 2019-09-24 13:50:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.