17

This question is about ZSH, not bash.

I have the following lines in my .zshrc file. Whenever I open a terminal I get a no matches found error referencing the line with the if statement.

if [[!( -a ~/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} )]]; then
    zkbd
fi

I read through the ZSH documentation and my if statement appears to be correct. I don't understand why I'm getting the error.

What I'd like to happen is for the zkbd utility to run if the file in the .zkbd folder does not exist.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Dave F
  • 573
  • 3
    @Gilles, how is that a duplicate? OK, in both cases, adding spaces fixes the problem, but considering as duplicates any question where the solution is to add spaces somewhere sounds wrong to me. – Stéphane Chazelas Aug 24 '15 at 13:09
  • @StéphaneChazelas How are they not duplicates? Both are asking why [ … ] doesn't work without spaces inside. – Gilles 'SO- stop being evil' Aug 24 '15 at 13:13
  • 3
    @Gilles, one is about the [ command, the other one about the [[...]] construct, one is about bash, the other one is about zsh. The error messages are completely different (at least it would make sense to explain why you get a no-match error in zsh here). – Stéphane Chazelas Aug 24 '15 at 13:19
  • 2
    @Gilles, also note that all of bash, ksh93 and mksh do support [[(a == b)]] (not [[!(a == b)]]), not zsh. – Stéphane Chazelas Aug 24 '15 at 13:35
  • don't ask questions you'll get yelled at every time because stackexchange got taken over by "a nicepeoples LONG ago" =~ s/ nicepeop/ssho/g – osirisgothra Sep 11 '23 at 13:38

1 Answers1

21

Thanks to don_crissti for answering this for me.

The correct if block is below.

if [[ ! -a ~/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} ]]; then
    zkbd
fi
Dave F
  • 573