@@ -560,11 +560,13 @@ public static void mainWithInputRedirection(String[] args, InputStream inputStre
560
560
BeeLine beeLine = new BeeLine ();
561
561
try {
562
562
int status = beeLine .begin (args , inputStream );
563
+ System .out .println ("after beeline.begin" );
563
564
564
565
if (!Boolean .getBoolean (BeeLineOpts .PROPERTY_NAME_EXIT )) {
565
566
System .exit (status );
566
567
}
567
568
} finally {
569
+ System .out .println ("mainWithInputRedirection ends, called finally" );
568
570
beeLine .close ();
569
571
}
570
572
}
@@ -577,6 +579,7 @@ public BeeLine(boolean isBeeLine) {
577
579
this .isBeeLine = isBeeLine ;
578
580
this .signalHandler = new SunSignalHandler (this );
579
581
this .shutdownHook = () -> {
582
+ info ("Running shutdown hook" );
580
583
try {
581
584
if (history != null ) {
582
585
history .save ();
@@ -1124,6 +1127,7 @@ public int begin(String[] args, InputStream inputStream, boolean keepHistory) th
1124
1127
initializeLineReader ();
1125
1128
if (isBeeLine ) {
1126
1129
int code = initArgs (args );
1130
+ info ("initArgs returns: " + code );
1127
1131
if (code != 0 ) {
1128
1132
return code ;
1129
1133
}
@@ -1306,6 +1310,7 @@ int runInit() {
1306
1310
}
1307
1311
}
1308
1312
}
1313
+ info (String .format ("initialized, exit: %s, executionResult: %d" , exit , executionResult ));
1309
1314
return executionResult ;
1310
1315
}
1311
1316
@@ -1372,13 +1377,15 @@ private int executeFile(String fileName) {
1372
1377
}
1373
1378
1374
1379
private int execute (LineReader reader , boolean exitOnError ) {
1380
+ System .out .println ("Execute with line reader" );
1375
1381
int lastExecutionResult = ERRNO_OK ;
1376
1382
Character mask = (System .getProperty ("jline.terminal" , "" ).equals ("jline.UnsupportedTerminal" )) ? null
1377
1383
: LineReaderImpl .NULL_MASK ;
1378
1384
1379
1385
String line ;
1380
1386
while (!exit ) {
1381
1387
try {
1388
+ info ("trying to parse next line" );
1382
1389
// Execute one instruction; terminate on executing a script if there is an error
1383
1390
// in silent mode, prevent the query and prompt being echoed back to terminal
1384
1391
line = (getOpts ().isSilent () && getOpts ().getScriptFile () != null ) ? reader
@@ -1398,6 +1405,7 @@ private int execute(LineReader reader, boolean exitOnError) {
1398
1405
lastExecutionResult = ERRNO_OK ;
1399
1406
}
1400
1407
} catch (EndOfFileException t ) {
1408
+ info ("EndOfFileException caught" );
1401
1409
/*
1402
1410
* If you're reading from a normal file (not from standard input or a terminal), JLine might raise an
1403
1411
* EndOfFileException when it reaches the end of the file. JLine uses readLine() for reading input, and it
@@ -1431,6 +1439,7 @@ private void setupHistory() throws IOException {
1431
1439
1432
1440
private void addBeelineShutdownHook () throws IOException {
1433
1441
// add shutdown hook to flush the history to history file and it also close all open connections
1442
+ info ("Add shutdown hook" );
1434
1443
ShutdownHookManager .addShutdownHook (getShutdownHook ());
1435
1444
}
1436
1445
@@ -1492,9 +1501,11 @@ private InputStream prepareInputStream(InputStream inputStream) {
1492
1501
1493
1502
protected Terminal buildTerminal (InputStream inputStream ) throws IOException {
1494
1503
if (inputStream != null ) { // typically when there is a file script to read from
1504
+ info ("Build terminal on stream" );
1495
1505
return TerminalBuilder .builder ().streams (inputStream , getErrorStream ()).build ();
1496
1506
} else { // no input stream, normal operation: proper behavior needs a system terminal
1497
1507
// system terminal can only be created with system streams
1508
+ info ("Build terminal on system in/err" );
1498
1509
return TerminalBuilder .builder ().system (true ).dumb (false ).streams (System .in , System .err ).build ();
1499
1510
}
1500
1511
}
0 commit comments