[Tarantool-patches] [PATCHv2 2/2] lua: fix tarantool -e always enters interactive mode

Artem artemreyt at tarantool.org
Sat Feb 20 14:27:25 MSK 2021


Thanks for the review!

>> diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h
>> index d76aedf7a..d5fdbc209 100644
>> --- a/src/lib/core/errinj.h
>> +++ b/src/lib/core/errinj.h
>> @@ -149,6 +149,7 @@ struct errinj {
>>       _(ERRINJ_AUTO_UPGRADE, ERRINJ_BOOL, {.bparam = false})\
>>       _(ERRINJ_COIO_WRITE_CHUNK, ERRINJ_BOOL, {.bparam = false}) \
>>       _(ERRINJ_APPLIER_SLOW_ACK, ERRINJ_BOOL, {.bparam = false}) \
>> +    _(ERRINJ_STDIN_ISATTY, ERRINJ_INT, {.iparam = -1}) \
>
> 1. according to name (ISATTY) variable can be in enabled or disabled 
> state so
>
> why do you use integer type here?

1. I use integer type for ISATTY cause this injection "overrides" return 
value of

standard isatty function for stdin. It can be set to 0 or 1. Default 
value -1 means

to use return value of standard function.

>>     ENUM0(errinj_id, ERRINJ_LIST);
>>   extern struct errinj errinjs[];
>> diff --git a/src/lua/init.c b/src/lua/init.c
>> index 25e8884a6..e7e0fe006 100644
>> --- a/src/lua/init.c
>> +++ b/src/lua/init.c
>> @@ -62,6 +62,7 @@
>>   #include "lua/swim.h"
>>   #include "lua/decimal.h"
>>   #include "digest.h"
>> +#include "errinj.h"
>>   #include <small/ibuf.h>
>>     #include <ctype.h>
>> @@ -583,6 +584,7 @@ run_script_f(va_list ap)
>>        */
>>       struct diag *diag = va_arg(ap, struct diag *);
>>       bool aux_loop_is_run = false;
>> +    bool option_e_runned = false;
>>         /*
>>        * Load libraries and execute chunks passed by -l and -e
>> @@ -613,6 +615,7 @@ run_script_f(va_list ap)
>>               if (luaT_call(L, 0, 0) != 0)
>>                   goto error;
>>               lua_settop(L, 0);
>> +            option_e_runned = true;
>>               break;
>>           default:
>>               unreachable(); /* checked by getopt() in main() */
>> @@ -627,25 +630,34 @@ run_script_f(va_list ap)
>>       fiber_sleep(0.0);
>>       aux_loop_is_run = true;
>>   +    int is_atty;
>
> 2. is_a_tty?
>
2. Done.



More information about the Tarantool-patches mailing list