-2

I'm just writing some small C scripts and testing them. Why dose

~ Desktop: gcc test.c -o test ; /Users/xx/Desktop/test ;

work just fine while

~ Desktop: gcc test.c -o test ; test ;

dose not work? Why dose OSX/ZSH need the full path to execute the binary?

wowpatrick
  • 4,559

1 Answers1

1

To be able to run executables from the current directory you need to add . to your PATH environment variable. This can be done by running PATH=$PATH:. within the shell or adding export PATH=$PATH:. to your ~/.zshrc.

The other alternative is to prefix the commands you wish to run with ./ making your command

~ Desktop: gcc test.c -o test ; ./test ;

Mattias
  • 611