Re: ssh-copy-id no newline bug

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Michael Stone <mstone@xxxxxxxxx> writes:

> On Tue, Mar 22, 2016 at 10:32:43PM +0100, Philip Hands wrote:
>>OK, it seems that tail from coreutils on Debian can deal with -1c as
>>well -- odd -- is this actually the portable option despite not being in
>>the manual?
>>
>>BTW can Solaris 10's tail handle it with a space after the c, thus:
>>
>>   tail -c 1
>
> That's the POSIX syntax.
>
> Friends don't let friends use the non-POSIX solaris utilities.

I guess that's a function of the PATH in use, and we don't have much
control over that unless I were to start adding weird tests in this
command line, so I'm not quite sure what you're trying to say there.

Anyway, having read the GNU coreutils info page, I see it supports the
-1c "obsolete" usage, and recent BSD manpages say they support the same
"historical" usage too, so the best bet would seem to be -1c (unless
there are some modern tail implementations that fail to support this).

On the strength of that, and having considered suggestions in this
thread, I'm settling on adding this after the ``mkdir .ssh &&'' :

  f=.ssh/authorized_keys && { [ -z "`tail -1c $f 2>/dev/null`" ] || echo >> $f ; } &&

I've inverted the test, in order that the series of &&'s can continue,
it's using -1c for tail, as that seems likely to be maximally portable,
likewise `` is more portable than $(), I don't see much benefit in
creating the file just so that the tail won't fail, so I've got the
2>/dev/null instead (I'm open to persuasion on that, since if one
creates the file, and doesn't discard the STDERR, then if tail manages
to fail for some other reason, we'd perhaps find out about it), and the
use of a variable ($f) removes duplication later in the line, and keeps
the line length under 255 which could conceivably be a limit in some
awful shell somewhere.

Did I miss anything?

Cheers, Phil.
-- 
|)|  Philip Hands  [+44 (0)20 8530 9560]  HANDS.COM Ltd.
|-|  http://www.hands.com/    http://ftp.uk.debian.org/
|(|  Hugo-Klemm-Strasse 34,   21075 Hamburg,    GERMANY

Attachment: signature.asc
Description: PGP signature

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux