[
https://issues.apache.org/jira/browse/IO-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17793424#comment-17793424
]
Miguel Munoz commented on IO-552:
---------------------------------
I am revising my view on this issue. My (Mac) shell only honors the tilde
character if it starts the file name, and is followed by a slash. Here's what
various commands do in my shell:
{{vi ~abc.txt}} — Creates a file called {{{}~abc.txt{}}}.
{{vi ~/abc.txt}} — Creates a file called {{abc.txt}} in my home directory.
{{vi abc~def.txt}} — Creates a file called {{abc~def.txt}}
{{vi abc~/def.txt}} — Tries to create a file called {{def.txt}} in a directory
called {{abc~ (In this case, the tilde is getting removed rather than expanded
as the home directory. This may be a bug in the shell.)}}
Apparently, my shell will only honor the tilde if it's followed by a slash.
(Bruno P. Kinoshita reports different behavior on his Linux system. He says the
tilde gets expaned on {{{}~kinow{}}}. So the slash isn't necessary.) However,
in spite of my shell's behavior, I don't really see much need to expand the
tilde in \{{abc~def.txt}}, especially in a method to concatenate file names.
But this issue is about the {_}second parameter{_}, which is never the start of
the file name. So now it looks like, for the second parameter, we should always
treat a tilde as a part of the file name, even if it's followed by a slash.
This also simplifies the solution. However, the JavaDocs should be very clear
about this.
> FilenameUtils.concat fails if second argument (fullFilenameToAdd) starts with
> '~' (tilde)
> -----------------------------------------------------------------------------------------
>
> Key: IO-552
> URL: https://issues.apache.org/jira/browse/IO-552
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.2, 2.5
> Environment: Windows 7 64bit, JavaVM 1.8 32bit
> Reporter: Jochen Tümmers
> Priority: Critical
> Time Spent: 2h 40m
> Remaining Estimate: 0h
>
> {{FilenameUtils.concat("c:/temp", "~abc.txt") returns "~abc.txt/" instead of
> "c:/temp/~abc.txt".}}
> As a result, the file would be created in the user's home directory instead
> of c:/temp.
> (Note: I Had to replace all instances of double backslashes that would
> normally appear in the java code with forward slashes as the editor cannot
> handle backslashes properly.)
> commons io 2.2. and 2.5 behave the same. 2.3 and 2.4 not tested.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)