diff options
author | LE Manh Cuong <cuong.manhle.vn@gmail.com> | 2016-06-19 03:26:03 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-19 14:07:04 -0700 |
commit | 01247e0299b34b9b46d96d5850a24583e39deabe (patch) | |
tree | 2b7bf47215372c03aa5bb2802777287d823a56de /compat/pread.c | |
parent | Git 2.5.5 (diff) | |
download | tgif-01247e0299b34b9b46d96d5850a24583e39deabe.tar.xz |
sh-setup: enclose setting of ${VAR=default} in double-quotes
We often make sure an environment variable is set to
something, either set by the user (in which case we do not
molest it) or set it to our default value (otherwise), with
: ${VAR=default value}
i.e. running the no-op command ":" with ${VAR} as its
parameters (or the default value we supply), relying on that
":" is a no-op.
This pattern, even though it is no-op from correctness point
of view, still can be expensive if the existing value in VAR
has shell glob (because they will be expanded against
filesystem entities) and IFS whitespaces (because the value
need to be split into multiple parameters). Our invocation
of ":" command does not care if the parameter given to it is
after the value in VAR goes through these processing.
Enclosing the whole thing in double-quote, i.e.
: "${VAR=default value}"
avoids paying the unnecessary cost, so let's do so.
Signed-off-by: LE Manh Cuong <cuong.manhle.vn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/pread.c')
0 files changed, 0 insertions, 0 deletions