14 ms·
> b) don't have a file named, say, `-a` in the current working directory. Rather: b) don't have a file with a single letter name in your CWD, like `a` Try th
by TeMPOraL 2y ago
> b) don't have a file named, say, `-a` in the current working directory.
Rather:
b) don't have a file with a single letter name in your CWD, like `a`
Try this:
touch a
ls -?
And yes, it's even more damning; you don't generally find legitimate files named `-a` or similar - rather, it's clear indication of someone invoking some CLI command wrong (`cp` comes to mind). However, single-letter files and folders are a relatively frequent thing to see.
- lloeki 2y agoHaha true, I missed the most obvious of all!
- me-vs-cat 2y ago> Try this: touch a; ls -? I don't see it. What are you trying to show with 'a' instead of '-l'? Why would a file named 'a' interact with a glob like '-?'? $ touch a $ ls -? zsh: no matches found: -? $ bash -c 'ls -?' ls: invalid option -- '?' Try 'ls --help' for more information. $ dash -c 'ls -?' ls: invalid option -- '?' Try 'ls --help' for more information. $ touch ./-l $ ls -? .rw-rw-r-- 0 user 10 Feb 18:32 -l .rw-rw-r-- 0 user 10 Feb 18:31 a
- TeMPOraL 2y agoZSH must handle globs in some weird way? '?' is glob for one character, '-?' means "dash followed by any character", and that's what I'd expect to be matched, and that's what my `ls` does.
- lloeki 2y ago> '-?' means "dash followed by any character" but `a` is not "dash followed by one character" so the glob does not match a `a` file? my haha nearby was wrong! I should have tested it :)
- me-vs-cat 2y agoI have a non-default option on for zsh, which is incredibly useful interactively. (Bash also has this option, but I haven't enabled it.) Normally, ls doesn't expand globs. Why did you say to try "touch a; ls -?"? What am I supposed to see from those two commands?