0

Recently, I came across a function to put in ~/.bashrc

gpip(){
   PIP_REQUIRE_VIRTUALENV="" pip "$@"
}

(Source)

I don't understand the use of $@. I guess that it sends to pip the argument passed to gpip from Terminal.

Is my understanding correct? What are those programming constructs called?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
chaudharyp
  • 3,394
  • 3
  • 26
  • 42
  • 2
    _"`$@` Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word."_ :: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html – hrbrmstr Oct 02 '15 at 04:15
  • or http://tldp.org/LDP/abs/html/internalvariables.html – hek2mgl Oct 02 '15 at 04:17
  • The code in your question wraps `pip` with `PIP_REQUIRE_VIRTUALENV` set to the empty string for the duration of the `pip` run. – tripleee Oct 02 '15 at 04:18

1 Answers1

1

"$@" is "interpolate all arguments, quoted individually", like "$1" "$2" "$3"....

So...

gpip "foo bar" "baz"

will call

PIP_REQUIRE_VIRTUALENV="" pip "foo bar" "baz"

man bash, then search for "Special Parameters". (This is not Mac-specific, it is a bash POSIX feature.)

Amadan
  • 191,408
  • 23
  • 240
  • 301
  • 4
    *[...] it's a `bash` feature.* More than that; `$@` is [specified by POSIX](http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_05_02). – jub0bs Oct 02 '15 at 04:18