News for hackers. Stuff that matters.
Re:Undergrad thought he had mastered Unix in weeks. Then he ... by TrainedMonkey on Monday November 18, 2024 @09:21AM (#42172500)
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/*`.
Re:Undergrad thought he had mastered Unix in weeks. Then he ... by mmh0000 on Monday November 18, 2024 @11:52AM (#42174250)
It 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
Re:Undergrad thought he had mastered Unix in weeks. Then he ... by einr on Monday November 18, 2024 @09:36AM (#42172616)
It 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 ~*     
  %
Re:Undergrad thought he had mastered Unix in weeks. Then he ... by account42 on Monday November 18, 2024 @09:30AM (#42172561)
It 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.
Re:Undergrad thought he had mastered Unix in weeks. Then he ... by PittleyDunkin on Monday November 18, 2024 @09:33AM (#42172576)
It says `tcsh` in the article.