0

As I compiling code with opencv, I found that people use pkg-config to get include and link information. For example,

g++ main.cpp `pkg-config --cflags --libs opencv`

However, as this post: Command substitution: backticks or dollar sign / paren enclosed? says, using $() is preferred.

g++ main.cpp $(pkg-config --cflags --libs opencv)

It seems that grave accent is more frequently in this situation. Why?

  • 1
    Back-ticks (as they are usually called) are older and because of that more ingrained in peoples mind. – Some programmer dude Oct 02 '17 at 09:11
  • 1
    Also, this have *nothing* to do with GCC or the `g++` command. – Some programmer dude Oct 02 '17 at 09:11
  • 3
    And/or, people don't learn shell properly, they just copy/paste somebody's broken code. – tripleee Oct 02 '17 at 09:12
  • To be fair, the thing that is broken here is `pkg-config` itself (by design), since it is assumed that the output can be used unquoted as arguments to `g++`. – chepner Oct 02 '17 at 12:24
  • A lot of folk grump about having to type a WHOLE EXTRA CHARACTER, but once they hit a situation where they need to embed one subcommand in another those self-matching parens start to look pretty good. :) – Paul Hodges Oct 02 '17 at 13:26

0 Answers0