mwhudson@ringil:~/src/ssh-import-id$ ssh-import-id gh:mwhudso
Username "mwhudso" not found at GitHub API
mwhudson@ringil:~/src/ssh-import-id$ ssh-import-id gh:mwhudso | cat
mwhudson@ringil:~/src/ssh-import-id$
What happened? The offending code looks like
if resp.status_code == 404:
print('Username "%s" not found at GitHub API' % ghid)
os._exit(1)
print does not flush by default. When stdout is a terminal you get an implicit flush on newline but when it's a pipe you do not and calling _exit(1) exits the process without flushing the buffers either. Two fixes suggest themselves: 1) add flush=True to the print() calls 2) exiting more conventionally by e.g. calling sys.exit()
mwhudson@ ringil: ~/src/ssh- import- id$ ssh-import-id gh:mwhudso ringil: ~/src/ssh- import- id$ ssh-import-id gh:mwhudso | cat ringil: ~/src/ssh- import- id$
Username "mwhudso" not found at GitHub API
mwhudson@
mwhudson@
What happened? The offending code looks like
if resp.status_code == 404:
print('Username "%s" not found at GitHub API' % ghid)
os._exit(1)
print does not flush by default. When stdout is a terminal you get an implicit flush on newline but when it's a pipe you do not and calling _exit(1) exits the process without flushing the buffers either. Two fixes suggest themselves: 1) add flush=True to the print() calls 2) exiting more conventionally by e.g. calling sys.exit()