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

Side by Side Diff: src/scripts/common.sh

Issue 1610021: Add sudo_clobber and sudo_append functions so that we can "echo" (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Common constants for build scripts 5 # Common constants for build scripts
6 # This must evaluate properly for both /bin/bash and /bin/sh 6 # This must evaluate properly for both /bin/bash and /bin/sh
7 7
8 # All scripts should die on error unless commands are specifically excepted 8 # All scripts should die on error unless commands are specifically excepted
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'.
10 # TODO: Re-enable this once shflags is less prone to dying. 10 # TODO: Re-enable this once shflags is less prone to dying.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 echo 142 echo
143 echo 143 echo
144 fi 144 fi
145 ;; 145 ;;
146 esac 146 esac
147 147
148 # ----------------------------------------------------------------------------- 148 # -----------------------------------------------------------------------------
149 # Functions 149 # Functions
150 150
151 function setup_board_warning { 151 function setup_board_warning {
152 echo 152 echo
153 echo "$V_REVERSE================= WARNING ======================$V_VIDOFF" 153 echo "$V_REVERSE================= WARNING ======================$V_VIDOFF"
154 echo 154 echo
155 echo "*** No default board detected in " \ 155 echo "*** No default board detected in " \
156 "$GCLIENT_ROOT/src/scripts/.default_board" 156 "$GCLIENT_ROOT/src/scripts/.default_board"
157 echo "*** Either run setup_board with default flag set" 157 echo "*** Either run setup_board with default flag set"
158 echo "*** or echo |board_name| > $GCLIENT_ROOT/src/scripts/.default_board" 158 echo "*** or echo |board_name| > $GCLIENT_ROOT/src/scripts/.default_board"
159 echo 159 echo
160 } 160 }
161 161
162 162
163 # Sets the default board variable for calling script 163 # Sets the default board variable for calling script
164 function get_default_board { 164 function get_default_board {
165 DEFAULT_BOARD= 165 DEFAULT_BOARD=
166 166
167 if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then 167 if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then
168 DEFAULT_BOARD=`cat "$GCLIENT_ROOT/src/scripts/.default_board"` 168 DEFAULT_BOARD=`cat "$GCLIENT_ROOT/src/scripts/.default_board"`
169 fi 169 fi
170 } 170 }
171 171
172 172
173 # Make a package 173 # Make a package
174 function make_pkg_common { 174 function make_pkg_common {
175 # Positional parameters from calling script. :? means "fail if unset". 175 # Positional parameters from calling script. :? means "fail if unset".
176 set -e 176 set -e
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 316 }
317 317
318 # Removes single quotes around parameter 318 # Removes single quotes around parameter
319 # Arguments: 319 # Arguments:
320 # $1 - string which optionally has surrounding quotes 320 # $1 - string which optionally has surrounding quotes
321 # Returns: 321 # Returns:
322 # None, but prints the string without quotes. 322 # None, but prints the string without quotes.
323 function remove_quotes() { 323 function remove_quotes() {
324 echo "$1" | sed -e "s/^'//; s/'$//" 324 echo "$1" | sed -e "s/^'//; s/'$//"
325 } 325 }
326
327 # Writes stdin to the given file name as root using sudo in overwrite mode.
328 #
329 # $1 - The output file name.
330 function sudo_clobber() {
331 sudo tee "$1" > /dev/null
332 }
333
334 # Writes stdin to the given file name as root using sudo in append mode.
335 #
336 # $1 - The output file name.
337 function sudo_append() {
338 sudo tee -a "$1" > /dev/null
339 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698