Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Issue 7049027: A less wordy version of r85947 and r85948 (Closed)

Created:
9 years, 7 months ago by Mark Mentovai
Modified:
9 years, 7 months ago
Reviewers:
TVL
CC:
chromium-reviews
Visibility:
Public.

Description

A less wordy version of r85947 and r85948. BUG=83180 TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=86039

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -3 lines) Patch
M chrome/installer/mac/dirdiffer.sh View 1 chunk +2 lines, -2 lines 2 comments Download
M chrome/installer/mac/keystone_install.sh View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 3 (0 generated)
Mark Mentovai
9 years, 7 months ago (2011-05-19 23:42:02 UTC) #1
TVL
lg http://codereview.chromium.org/7049027/diff/1/chrome/installer/mac/dirdiffer.sh File chrome/installer/mac/dirdiffer.sh (right): http://codereview.chromium.org/7049027/diff/1/chrome/installer/mac/dirdiffer.sh#newcode164 chrome/installer/mac/dirdiffer.sh:164: : ${DIRDIFFER_NO_DIFF:=} i'll trust you on this syntax, ...
9 years, 7 months ago (2011-05-20 02:14:01 UTC) #2
Mark Mentovai
9 years, 7 months ago (2011-05-20 02:26:35 UTC) #3
http://codereview.chromium.org/7049027/diff/1/chrome/installer/mac/dirdiffer.sh
File chrome/installer/mac/dirdiffer.sh (right):

http://codereview.chromium.org/7049027/diff/1/chrome/installer/mac/dirdiffer....
chrome/installer/mac/dirdiffer.sh:164: : ${DIRDIFFER_NO_DIFF:=}
TVL wrote:
> i'll trust you on this syntax, it isn't one I've seen before.

:= does an assignment within the expansion if the variable is unset or empty.
The : up front just tells the shell to throw away the result of the expansion.
So the shell does the expansion, which does the assignment, and then chucks it
out. If the variable started off as unset (or empty), it’ll wind up set (or
reset) to empty. Exactly what we want.

mark@rj bash$ declare -p VAR && echo "${VAR}"
-bash: declare: VAR: not found
mark@rj bash$ : ${VAR:=}
mark@rj bash$ declare -p VAR && echo "${VAR}"
declare -- VAR=""

mark@rj bash$ VAR=yes
mark@rj bash$ : ${VAR:=}
mark@rj bash$ declare -p VAR && echo "${VAR}"
declare -- VAR="yes"
yes

Powered by Google App Engine
This is Rietveld 408576698