linter-gcc icon indicating copy to clipboard operation
linter-gcc copied to clipboard

Relative paths are relative to Atom's $PWD, not the project root

Open Bruno02468 opened this issue 5 years ago • 0 comments

Suppose I invoke Atom from dmenu (making it start under /home/bruno), and it auto-reopens my last project, under /home/bruno/Git/project. Upon saving, linter-gcc should run gcc from /home/bruno/Git/project as said in the package description ("Paths are expanded relative to the project that contains the file being linted.").

However, gcc runs under /home/bruno, thus breaking all the relative include paths specified in .gcc-flags.json., among other things.

In order to reproduce/prove, edit the config file and replace /usr/bin/gcc with a path to some shell script that reports its own $PWD, such as one containing the command xmessage "at: $PWD --- args: $*" &, which will simply open a pop-up with its $PWD and parameters. Then, just launch atom from any folder, letting it reopen the last project, save a C source file, and wait for it.

The linter is therefore unusable unless I start Atom from the exact project folder every time (not convenient) or specify absolute paths everywhere (not portable). Besides, this is arguably a security flaw too, since broken relative paths can be made to lead to files the user does not intend on compiling... keep in mind the C preprocessor alone can do arbitrary computation.

Bruno02468 avatar Jul 14 '20 15:07 Bruno02468