3 ms·
> rm -rf ~* I'm more curious about the ~* part. Is the behavior triggered by a tcsh peculiarity that no longer works that way these days? Why would ~* trigger
by buran77 2y ago
> rm -rf ~*
I'm more curious about the ~* part. Is the behavior triggered by a tcsh peculiarity that no longer works that way these days? Why would ~* trigger he behavior of deleting every home directory?
And aren't Emacs backup names appended with ~ rather than prepended? In that case shouldn't it be "~" (anything ending in ~) instead of "~*"?
The story sounds a bit flimsy regardless. Not that it's improbable but rather the opposite, rm -rf* stories are a dime a dozen.
- justin66 2y agoRecursively remove everything in the home directory.
- einr 2y agoNo, that would be ~/* or just ~. The article says that the command deleted every user's home directory, which seems to imply that the shell would expand ~* to a list of every user's home directory. But -- sensibly -- neither modern tcsh, bash, zsh, ksh nor the ancient csh in NeXTStep does that. csh on NeXTStep 1.0: localhost> echo ~ /me localhost> echo ~* echo: No match.
- blakesterz 2y agoMy first thought was wanting to get rid those files that emacs leaves behind.
- deleted 2y ago[deleted]
- andai 2y agoHere's my reading: this ran in /home/ for some reason, where all the homedirs had a name pattern like ~stuff.
- matrss 2y ago~username expands to the home directory of username. There might have been a shell that likewise expanded ~* to all home directories.
- TrainedMonkey 2y agoOn zsh `~` expands to home directory, while `ls ~*` does not do anything: alex@world RevelCode % echo ~ /Users/Alex alex@world RevelCode % ls ~* alex@world RevelCode % I am also curious how `~*` expanded to an equivalent of `/users/*`.
- account42 2y agoIt kind of makes sense that if you have ~username and wildcards that you can then apply those wildcards to the username as well and not just real files and directories.
- PittleyDunkin 2y agoIt says `tcsh` in the article.
- einr 2y agoIt does not "not do anything", it expands to a list of your files that have a filename starting with ~. You just don't happen to have any in the current directory ;) And yes, this is a potential footgun: % touch ~test zsh: no such user or named directory: test % touch "~test" % ls ~* ~test % rm ~test zsh: no such user or named directory: test % rm "~test" % ls ~* %
- mmh0000 2y agoIt partially depends on Zsh's NOMATCH and NULL_GLOB setopt: NOMATCH - print error when glob doesn't match; NO_NOMATCH - print literal GLOB character: setopt NOMATCH ls * => zsh: no matches found: * setopt NO_NOMATCH ls * => ls '*' NULL_GLOB - when glob doesn't match, return blank; (Overrides NOMATCH): setopt NULL_GLOB ls * => ls '' # Brings behavior inline with RHEL/Bash4 defaults: setopt NO_NOMATCH
- MayeulC 2y agoLikewise. Quite a few people here not realizing this is likely (t)csh-specific. I ran a quick test on multiple tcsh versions I had installed, the oldest being 6.13 (2004, RedHat 4). All returned 'Unknown user: *.' It wouldn't surprise me if at some point this expanded to every user's home directory, the way '~username' expands to /home/username, or wherever that user's home is. I couldn't find anything of note in https://github.com/tcsh-org/tcsh/blob/master/Fixes https://github.com/tcsh-org/tcsh/blob/master/Fixes
- einr 2y agoI couldn't say for sure that some UNIX shell somewhere at some point did not do home directory wildcard expansion -- seems like a WMD grade foot gun, but OK -- but as you've noticed, tcsh does not do it and in fact even if you go back to csh in NeXTStep from 1989 it doesn't do it either. Try it yourself: https://infinitemac.org/1989/NeXTStep%201.0 https://infinitemac.org/1989/NeXTStep%201.0
- ruthmarx 2y agoI don't think the tilde is referring to a shortcut for a home directory here, rather I think it's the first character in the filenames of the backup files he was trying to delete.