3 ms·
On zsh `~` expands to home directory, while `ls ~*` does not do anything: alex@world RevelCode % echo ~ /Users/Alex alex@world RevelCode % ls ~* alex@w
by TrainedMonkey 2y ago
On 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