Bug 377978 - Unable to create new folder named "~" without using escape character
Summary: Unable to create new folder named "~" without using escape character
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Manjaro Linux
: NOR minor
Target Milestone: ---
Assignee: David Faure
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2017-03-23 15:28 UTC by Giorgi Gzirishvili
Modified: 2020-05-29 22:01 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.71.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giorgi Gzirishvili 2017-03-23 15:28:50 UTC
Go to Dolphin and create a new folder using context menu → Create New → Folder... (or F10 key by default). Type in "~" (without quotes) as its name. Nothing will be created. However, if you escape it with "\" like this: "\~", a folder named "~" will be created. My distro is Manjaro KDE 17 (Gellivara). Dolphin version number is 16.12.3 (the report form didn't allow me to select anything above 16.12.0).
Comment 1 Christoph Feck 2017-03-24 02:18:46 UTC
This is consistent with POSIX behavior. In a bash shell, doing "mkdir ~" within a directory also says "mkdir: cannot create directory ‘/home/user’: File exists", while "mkdir \~" works.

~ in Unix is your home folder (and ~user is /home/user), so we probably should not silently allow creating directory names that start with a tilde character, but warn instead.
Comment 2 Giorgi Gzirishvili 2017-03-25 08:48:48 UTC
I know, I know... My point is if you're typing a name in a field, it should assume quotation marks around it; otherwise, it'd be necessary to escape spaces and other special characters too. So, try 'mkdir "~"' instead, it works flawlessly. Moreover, even if it's an intentional feature, it should at least display an error message and it just does nothing instead. Also, it's GUI, so it should be easy to use even for noobs.
Comment 3 Giorgi Gzirishvili 2017-03-25 09:04:00 UTC
The current behaviour is undoubtedly inconsistent. You can create a folder named "'", " ", or "\" without escaping the characters and when you do escape them, it results in the name containing the escape character too, like "\'", "\ ", or "\\".

This contrasts with what happens in the case of "~" as a name.
Comment 4 Giorgi Gzirishvili 2017-03-25 09:15:51 UTC
Also an unintentional behaviour similar to this one:

When you're trying to create a folder named "." or "..". Dolphin displays a warning saying "The name "." starts with a dot, so the directory will be hidden by default.", but after you click "Create directory" button and it fails to do so (obviously, you can't create these two under a *nix system), it doesn't even display an error message.

I'm not sure if I should file another bug report regarding this.
Comment 5 Nate Graham 2017-11-28 21:04:50 UTC
Yeah, this isn't very user-friendly. We don't require escape sequences for spaces and ampersands and the like; tildes should be the same way.

Giorgi Gzirishvili, please do file another bug to track that. If we have multiple issues tracked in one bug, when the bug gets closed after one of them is fixed, the other issues are lost.
Comment 6 Giorgi Gzirishvili 2017-11-29 20:17:36 UTC
Nate Graham, Done.

https://bugs.kde.org/show_bug.cgi?id=387449

Regarding this bug, I think it'd be better if Dolphin displayed a warning that creating a folder named "~" isn't recommended since if the user accidentally does "rm -r ~" (without escaping ~) from the shell, it'll remove the user's home folder instead.
Comment 7 Ahmad Samir 2020-05-29 22:01:06 UTC
Git commit 610435c11ff7d1d8cba415995bcb2810e87209a2 by Ahmad Samir.
Committed on 28/05/2020 at 09:24.
Pushed by dfaure into branch 'master'.

[KnewFileMenu] Allow creating a dir named '~'

It is a weird name for a dir, but it's better to allow such an operation
rather than fail silently.

FIXED-IN: 5.71.0

M  +9    -8    src/filewidgets/knewfilemenu.cpp

https://invent.kde.org/frameworks/kio/commit/610435c11ff7d1d8cba415995bcb2810e87209a2