zsh: command not found: ls

function, loops, zsh

Solution

The problem is assigning the `path` variable - since zsh has that variable reserved (in addition to PATH), overwriting it removes the ability for the shell to find any command.

The correct answer, of course, is to use a variable other than `$path`:

local_path=/tmp    
for i in ${local_path}/*; do
  echo $i
done

Problem

I'm having a rather strange problem with zsh. When I start up my shell, everything - functions, environment vars, aliases, etc. - all work fine. I've created the following function and sourced it in zsh: ``` clean() { path=/tmp for i in ${path}/*; do echo $i done } ``` Running `clean` in the terminal works as expected, in that it prints out all the files in /tmp/. Afterward, however, trying any command - for example, ls - produces this: ``` zsh: command not found: ls ``` I have several other functions that work just fine, which leads me to believe that somehow, that loop is causing the problem. At any rate, this is very frustrating and I would sincerely appreciate the community's eyes. Thanks!

Original source