having an explicit flag to control their buffering behavior,
typically -i for interactive, or by a special environment variable.

Would that fix it? Where does the -i flag go?

I am using Emacs 25.2.1 with Evil Spacemacs and Ivy on Linux.

UPDATE_1

The interactive program works when shell-commend is called with asynchronously option:

SPC SPC (counsel-M-x) async-shell-command
Enter a number: 2
howmany=2

From Emacs help describe-function shell-command:

shell-command is an interactive compiled Lisp function in ‘simple.el’.
...
If COMMAND ends in ‘&’, execute it asynchronously.
The output appears in the buffer ‘*Async Shell Command*’.
That buffer is in shell mode. You can also use
‘async-shell-command’ that automatically adds ‘&’.
Otherwise, COMMAND is executed synchronously. The output appears in
the buffer ‘*Shell Command Output*’.