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

Issue 5840003: Allow specifying environment variables w/ enter_chroot again. (Closed)

Created:
10 years ago by diandersAtChromium
Modified:
9 years, 6 months ago
Reviewers:
kliegs, scottz, sosa
CC:
chromium-os-reviews_chromium.org, Mandeep Singh Baines, anush, sosa
Visibility:
Public.

Description

Allow specifying environment variables w/ enter_chroot again. Examples of how people might be using enter_chroot: 1. ./enter_chroot [chroot_flags] VAR1=val1 VAR2=val2 -- cmd arg1 arg2 Set env vars and run cmd w/ args 2. ./enter_chroot [chroot_flags] VAR1=val1 VAR2=val2 Set env vars and run shell 3. ./enter_chroot [chroot_flags] -- cmd arg1 arg2 Run cmd w/ args 4. ./enter_chroot [chroot_flags] VAR1=val1 VAR2=val2 cmd arg1 arg2 Like #1 _if_ args aren't flags (if they are, enter_chroot will claim them) 5. ./enter_chroot [chroot_flags] cmd arg1 arg2 Like #3 _if_ args aren't flags (if they are, enter_chroot will claim them) I also updated the help to indicate that whole-command quoting is no longer supported. If you really need whole-command quoting (maybe you want in- chroot redirection), you'll need to use sh -c like: ./enter_chroot.sh -- sh -c "echo \"Save me\" > /tmp/save.txt" You should avoid single quotes in the command and arguments. This isn't a new limitation: it's shflags related. Change-Id: I0452a8730ac9b8197834edc753b9eece69896135 BUG=chromium-os:7072 TEST=Tried a whole bunch of these commands. Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=9362fa8

Patch Set 1 #

Total comments: 4

Patch Set 2 : Fixed desc for case #2 from previous submit. #

Patch Set 3 : Use nicer syntax for test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+38 lines, -8 lines) Patch
M enter_chroot.sh View 1 2 2 chunks +38 lines, -8 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
diandersAtChromium
Jon, I think this will fix things to re-allow specifying environment variables w/ enter_chroot, as ...
10 years ago (2010-12-16 22:08:53 UTC) #1
kliegs
LGTM but make sure someone else signs off on the hackiness (or not) of the ...
10 years ago (2010-12-16 22:26:33 UTC) #2
diandersAtChromium
Jon, Thanks! Yes, I had a paste-o on the description for #2. Fixed in the ...
10 years ago (2010-12-16 22:30:21 UTC) #3
sosa
Can you make this less bash-y and more sh-y? http://codereview.chromium.org/5840003/diff/1/enter_chroot.sh File enter_chroot.sh (right): http://codereview.chromium.org/5840003/diff/1/enter_chroot.sh#newcode74 enter_chroot.sh:74: ...
10 years ago (2010-12-16 22:32:44 UTC) #4
scottz
This also seems fine to me. I don't foresee any problems but I know this ...
10 years ago (2010-12-16 22:32:47 UTC) #5
diandersAtChromium
10 years ago (2010-12-16 22:43:01 UTC) #6
Thanks to everyone for the quick reviews.  I'm going to push this...

http://codereview.chromium.org/5840003/diff/1/enter_chroot.sh
File enter_chroot.sh (right):

http://codereview.chromium.org/5840003/diff/1/enter_chroot.sh#newcode74
enter_chroot.sh:74: _FLAGS_FIXED="${_FLAGS_FIXED:+${_FLAGS_FIXED} }'$1'"
Going to leave this, since it's copied almost verbatim from shflags.

On 2010/12/16 22:32:45, sosa wrote:
> can you do this less bashy?  i.e. _FLAGS_FIXED="${_FLAGS_FIXED} $1"

http://codereview.chromium.org/5840003/diff/1/enter_chroot.sh#newcode75
enter_chroot.sh:75: if [[ "${_SAW_DASHDASH} $1" == "0 --" ]]; then
On 2010/12/16 22:32:45, sosa wrote:
> Prefer if you split this into two checks that are and'd i.e. [$_SAW_DASHDASH
-eq
> 0 ] && [[ $1 == "--" ]]; then

Done.

Powered by Google App Engine
This is Rietveld 408576698