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