Why this peaces of code dont't run the same.
samuel@corny ~ $ echo "pippo\npluto\nminnie\ntopolino" | @(lambda a,s=None: s.read())
pippo
pluto
minnie
topolino
Second command
samuel@corny ~ $ echo "pippo\npluto\nminnie\ntopolino" | @(lambda a,s=None: s.readlines())
pippo
pluto
Is the python readlines uncorrect for read line by line the input Pipe.
My version of Xon.sh is 0.7.8
So this is somewhat subtle, but callable aliases (which lambdas are one type of), have a few different kinds of objects that they can return. One of which is a tuple of
(stdout, stderr, returncode)
.The
str.readlines()
method returns a list, which in this case is['pippo\n', 'pluto\n', 'minnie\n', 'topolino\n']
. So, here,stdout = "pippo\n"
stderr = "pluto\n"
returncode
is never printed, but happens to be"minnie\n"
hereThis is probably not the intended behavior and is why the first example works.