Edit PATH by adding current directory. To compile a *.c file without by typing a filename without "./"

StackOverflow https://stackoverflow.com/questions/20358587

  •  28-08-2022
  •  | 
  •  

Вопрос

I added this line:

PATH=.:$PATH

to my .bash_profile.

Now I have to make main.c compile when I type zz (under the same directory in ~/user/filename)

  1. What do I have to write in the zz shell script?
  2. Did I add the current directory correctly?
Это было полезно?

Решение

PATH determines where executables are searched; it has no influence on where source files are searched. Source files without a directory component are searched in the current directory anyway. What you have to write to compile main.c depends on the compiler used, which you didn't specify, but it's usually like cc main.c. Also consider using make rather than writing a shell script.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top