Keychain ssh responses should end in a newline

Keychain ssh URLs like should end in a newline.

Why this matters:

I wanted to write a script what would grab the keychain URL and write ssh keys to authorized_keys. I want this to work ‘everywhere’, so I’m using sh and read. read returns a nonzero exit status when the last line does not have a terminating newline.


$ ( WHO=hug; curl -o - --no-progress-meter${WHO}/ssh | read FOO; echo $? )

$ echo "hi" | read FOO; echo $?
$ ( WHO=hug; curl -o - --no-progress-meter${WHO}/ssh | hexdump -C | tail -n2)
00000050  20 68 75 67 40 6f 6d 67  2e 6c 6f 6c              ||

$ ( echo "foo" | hexdump -C)
00000000  66 6f 6f 0a                                       |foo.|

Script, if you’re interested:
Unrelated, there’s no forum category for keychain.

1 Like

Yikes, I didn’t know about this — thanks for schooling me on the issue. It was a quick and easy fix, which is live now. Let me know if you notice any other issues related to it!