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

Side by Side Diff: tools/gn/command_args.cc

Issue 654333002: gn: Check GN_EDITOR before EDITOR in environment variables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lrn2spl Created 6 years, 2 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium 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 #include <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 "\"...\n"); 189 "\"...\n");
190 ::WaitForSingleObject(info.hProcess, INFINITE); 190 ::WaitForSingleObject(info.hProcess, INFINITE);
191 ::CloseHandle(info.hProcess); 191 ::CloseHandle(info.hProcess);
192 } 192 }
193 return true; 193 return true;
194 } 194 }
195 195
196 #else // POSIX 196 #else // POSIX
197 197
198 bool RunEditor(const base::FilePath& file_to_edit) { 198 bool RunEditor(const base::FilePath& file_to_edit) {
199 // Prefer $VISUAL, then $EDITOR, then vi. 199 // Prefer $VISUAL, then $EDITOR, then vi.
brettw 2014/10/15 21:11:20 Maybe just remove this comment?
200 const char* editor_ptr = getenv("VISUAL"); 200 const char* editor_ptr = getenv("VISUAL");
201 if (!editor_ptr) 201 if (!editor_ptr)
202 editor_ptr = getenv("GN_EDITOR");
203 if (!editor_ptr)
202 editor_ptr = getenv("EDITOR"); 204 editor_ptr = getenv("EDITOR");
203 if (!editor_ptr) 205 if (!editor_ptr)
204 editor_ptr = "vi"; 206 editor_ptr = "vi";
205 207
206 std::string cmd(editor_ptr); 208 std::string cmd(editor_ptr);
207 cmd.append(" \""); 209 cmd.append(" \"");
208 210
209 // Its impossible to do this properly since we don't know the user's shell, 211 // Its impossible to do this properly since we don't know the user's shell,
210 // but quoting and escaping internal quotes should handle 99.999% of all 212 // but quoting and escaping internal quotes should handle 99.999% of all
211 // cases. 213 // cases.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 "Or see \"gn help args\" for more variants.").PrintToStdout(); 337 "Or see \"gn help args\" for more variants.").PrintToStdout();
336 return 1; 338 return 1;
337 } 339 }
338 340
339 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) 341 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList))
340 return ListArgs(args[0]); 342 return ListArgs(args[0]);
341 return EditArgsFile(args[0]); 343 return EditArgsFile(args[0]);
342 } 344 }
343 345
344 } // namespace commands 346 } // namespace commands
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