Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [ -d (#i)Temp ]



On Fri, Apr 10, 2026 at 8:36 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> 2 /aWorking/Zsh/Source/Wk 3 % md temp  # in addition to /Temp
>
> 2 /aWorking/Zsh/Source/Wk 3 % [[ -d ''(#i)Temp(#qN) ]] && echo "it's a
> directory"
>
> 2 /aWorking/Zsh/Source/Wk 3 % rm -r temp
>
> 2 /aWorking/Zsh/Source/Wk 3 % [[ -d ''(#i)Temp(#qN) ]] && echo "it's a
> directory"
> it's a directory
>
> ... seems to fail with more than one match, exactly as desired. Seems
> perfect unless there' some gotcha.

It's checking for a directory named "Temp temp", which does not exist,
so you are getting the result you want by accident.

The simplest way I know of to achieve what you want:

  local d=( (#i)Temp(/N) )
  [[ ${#d} == 1 ]] && echo "there is exactly one (#i)Temp directory"

Note that this test succeeds if there is a directory named "temp" and
a regular file named "Temp". I presume that's what you want.

Roman




Messages sorted by: Reverse Date, Date, Thread, Author