Re: [ -d (#i)Temp ]

Roman Perepelitsa <[email protected]> Fri, 10 Apr 2026 20:48:21 +0200
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <CAN=4vMr_wYRcX7bbmMp+3MxOdcQ47XWZTLFDLudr523wbQmA+Q@mail.gmail.com>
On Fri, Apr 10, 2026 at 8:36 PM Ray Andrews <[email protected]> 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