4 ms·
In academia, I get (and used to create) pdfs with names like: "On the number of associative foobars of degree blah - Johnson and Anderson.pdf" all the time
by ykonstant 2y ago
In academia, I get (and used to create) pdfs with names like:
"On the number of
associative foobars
of degree blah -
Johnson and Anderson.pdf"
all the time. It is very convenient for non-technical academics to have a descriptive file name, and to be able to see it entirely in the navigator they use newlines.
- ykonstant 2y agoI am interested in hearing the rationale for downvotes explicitly. I am describing a reality that exists and must be taken into account. Why are you downvoting?
- oneeyedpigeon 2y agoOh god. I already get upset enough by spaces in a file name, although I realise that fight is basically lost now!
- enriquto 2y agoAs a fellow spaces-in-filenames-hater, the fight is not lost. We are on the brink of winning it; it's just a mount option away! While we cannot avoid that people hit the spacebar when writing a filename on a gui, this does not mean at all that the resulting filename itself need contain a plain space character. Those spaces can and should be transparently translated to non-breaking space characters at some point. Maybe by the gui itself, or more robustly by the filesystem. This would make everybody happy: gui users and naive shell script writers.
- poincaredisk 2y ago>Those spaces can and should be transparently translated to non-breaking space characters at some point Why? This just introduces more complexity and interoperability headaches for seemingly no reason.
- enriquto 2y ago> Why? In order to preserve the sacrosanct simplicity of naive shell scripts. Seems like a very noble goal to me. The only unexpexted compexity arises when you want to deal with filenames having mixed spaces and nbsps. But I'd say that people who do that had it coming.
- alexvitkov 2y agoIf you want simple shell scripts to work, make an actually good shell language without all the footguns. The filesystem is way more important than /bin/sh and and any complexity added there will trickle down to all programs, not just shell scripts. It's not worth adding hacks on the FS to patch defects in poorly written shell scripts (which are being replaced en masse with python/nodejs/even weirder yaml files/systemd units/etc... anyways)
- ksp-atlas 2y agonushell uses real lists for things which means you don't need to care about seperators except when dealing with external system things
- consteval 2y agoWhitespace in filenames in general is difficult to deal with. Many, maybe most, programs get it wrong. It's not just about shell scripts, many GUI programs fail to handle those files properly too.
- alexvitkov 2y agoWhen GUI programs mishandle filenames with spaces, IME it's usually because they spawn a subshell in a naive way (system("rm " + filename)). To mishandle spaces you have to split an input w/ filenames by whitespace, which is not that common of an operation outside of a shell.
- InfiniteRand 2y ago
- vbezhenar 2y agoYep, works today: sh-3.2$ f='Hello world' sh-3.2$ echo $f Hello world sh-3.2$ for i in $f; do echo $i; done Hello world sh-3.2$ f='Hello\xC2\xA0world' sh-3.2$ echo $f Hello world sh-3.2$ for i in $f; do echo $i; done Hello world
- stouset 2y agoJust always quote variable interpolation and you will never have problems. sh-3.2$ f='Hello world' sh-3.2$ echo "${f}" Hello world sh-3.2$ for i in "${f}"; do echo "${i}"; done Hello world sh-3.2$
- chasil 2y agoIt would be really nice if there was a mount option that would quietly remove spaces in filenames, or convert them to an underscore. If I had it, I would use it today.
- curt15 2y agoDidn't Windows name "Program Files" with a space to force application developers to handle spaces in paths properly?
- ape4 2y agoNot to mention C:\Program Files (x86)
- account42 2y agoAnd C:\Programme and other localized variants to force people to go through the proper APIs instead of hardcoding paths.
- pjmlp 2y agoIn theory yes, in practice to this day many people don't bother how to learn how to deal with pathnames in a proper way.
- inetknght 2y agoTop difficulties in computer science: 1. naming things 2. cache coherency 3. off-by-one errors ??? 4. quoting pathnames
- nneonneo 2y agoEh, maybe. In practice I usually do all my moderately-heavy filesystem scripting in Python these days, for which pathname quoting is just a complete non-issue. Of course, I still use a shell for quick-and-dirty stuff, but usually only for pretty simple tasks where the simplest quoting setup ("$i") suffices.
- hawski 2y agoI would replace 4 with parameter expansion rules.
- mmcdermott 2y agoFor the longest time you could get away with this in cmd: > dir c:\progra~1 So if forcing people to handle spaces was the goal, it took a long time to force it.
- jonhohle 2y agoConvince (force?) your team to use make and soon everyone will forget spaces in file names are even a thing!
- taneliv 2y agoMy team already uses `make` but there's no reason for me to run it in my Downloads folders. File names in there are sometimes wild. Yet I expect command line tools to work with them. If they will cease to do so, I will have to start using non-POSIX variants of those tools, I guess.
- Flimm 2y agoHow do these non-technical academics even create a PDF file with a name like that?
- ykonstant 2y agoRight click, rename, enter, enter, enter (until the entire file name is visible on the box)? That's how I did it when I used Windows. Edit: now I remember the most basic way: open the pdf, select and copy the title, click on rename and paste from clipboard. Works great to get the file name with the newlines exactly as they are on the title!
- zelphirkalt 2y agoDoesn't <enter> just confirm the typed input for the filename and finish the renaming? How does that insert newlines?
- ykonstant 2y agoShrug, I last used windows with Windows 7, so you are probably right. That being said, at least two of the students I am currently tutoring are on XP and one of my colleagues as well :D
- astroid 2y agoYes - I just tested on Win10+11 because I thought "there is no way I didn't accidentally do something like this on accident... and I would have remembered seeing a new line in my file name when I made that mistake." I just opened a folder in file explorer, clicked 'rename' and then tried the following combinations: Enter L Ctrl + Enter L Alt + Enter Win + Enter R Ctrl + Enter R Alt + Enter None of them let me put new lines in the filename - it either did nothing, or 'closed' the rename view.
- jodrellblank 2y agoI don't know who "the Austin Group" mentioned in the article are, but how come they "could not find a single use-case for newlines in pathnames besides breaking naive scripts" when legitimate use-cases are so easy to find? (And if they're that incompetent, why does the article imply they are worth quoting and listening to?)
- gpderetta 2y agoIt is [1] the joint working group that for the last 25+ years has been responsible for both the POSIX standard and the Single Unix Specification. It emerged after the UNIX wars as a consolidation of the various splintered UNIX standardization efforts (POSIX itself, X/OPEN, OSF, etc). [1] https://en.wikipedia.org/wiki/Austin_Group https://en.wikipedia.org/wiki/Austin_Group
- nilamo 2y agoIs that legitimate? A path name is just a unique identifier for a file, IMO it doesn't make sense to put a whole novel in there. If anything, a giant summary like that should be in the meta tags?
- jodrellblank 2y agoIn what way is it not legitimate? It's not an accident, bug or data corruption. Someone put it there for a reason, and it benefits their use case. That's as legitimate as it gets.
- ykonstant 2y agoThat's a core part of the problem: a path name is NOT just a unique identifier for a file. Desktop operating systems and their classical utilities conflate the "unique identifier" and whatever "displayed title" of a file though which the end user interacts with the file. Users care about "titles" or "summaries" of files, not "filesystem identifiers"; as long as the two are conflated, non-technical users will use the identifier to write titles and thus make the file easy to locate in an interactive GUI. Meta tags are not even in the cognitive horizon of most people.
- 2y ago