File tree 1 file changed +12
-13
lines changed
src/Common/Commands.Common
1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -254,28 +254,27 @@ protected void SaveDataCollectionProfile()
254
254
255
255
protected bool CheckIfInteractive ( )
256
256
{
257
- if ( this . Host == null || this . Host . UI == null || this . Host . UI . RawUI == null )
258
- {
259
- return false ;
260
- }
261
-
262
257
bool interactive = true ;
263
- try
258
+ if ( this . Host == null || this . Host . UI == null || this . Host . UI . RawUI == null )
264
259
{
265
- var test = this . Host . UI . RawUI . KeyAvailable ;
260
+ interactive = false ;
266
261
}
267
- catch ( HostException ex )
262
+ else
268
263
{
269
- if ( ex . Message . StartsWith ( "A command that prompts the user failed" ) )
264
+ try
270
265
{
271
- interactive = false ;
266
+ var test = this . Host . UI . RawUI . KeyAvailable ;
272
267
}
273
- else
268
+ catch
274
269
{
275
- throw ex ;
270
+ interactive = false ;
276
271
}
277
272
}
278
273
274
+ if ( ! interactive && ! _dataCollectionProfile . EnableAzureDataCollection . HasValue )
275
+ {
276
+ _dataCollectionProfile . EnableAzureDataCollection = false ;
277
+ }
279
278
return interactive ;
280
279
}
281
280
@@ -288,7 +287,7 @@ protected void PromptForDataCollectionProfileIfNotExists()
288
287
// Initialize it from the environment variable or profile file.
289
288
InitializeDataCollectionProfile ( ) ;
290
289
291
- if ( CheckIfInteractive ( ) && ! _dataCollectionProfile . EnableAzureDataCollection . HasValue )
290
+ if ( ! _dataCollectionProfile . EnableAzureDataCollection . HasValue && CheckIfInteractive ( ) )
292
291
{
293
292
WriteWarning ( Resources . DataCollectionPrompt ) ;
294
293
You can’t perform that action at this time.
0 commit comments