Bug 1530 - ssh-copy-id: strip colon from end of hostname
Summary: ssh-copy-id: strip colon from end of hostname
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 5.1p1
Hardware: Other Linux
: P2 trivial
Assignee: Assigned to nobody
URL: http://bugs.debian.org/cgi-bin/bugrep...
Keywords:
Depends on:
Blocks: V_5_6
  Show dependency treegraph
 
Reported: 2008-10-09 22:59 AEDT by Colin Watson
Modified: 2010-08-27 10:28 AEST (History)
2 users (show)

See Also:


Attachments
strip colon from end of hostname (778 bytes, patch)
2008-10-09 22:59 AEDT, Colin Watson
no flags Details | Diff
openssh-ssh-copy-id.patch (831 bytes, text/plain)
2010-08-03 16:21 AEST, Darren Tucker
djm: ok+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Watson 2008-10-09 22:59:35 AEDT
Created attachment 1573 [details]
strip colon from end of hostname

When using ssh-copy-id, people often suffix the hostname with a colon, by subconscious analogy with scp. It would be nice to make this silently work. The attached patch does this.
Comment 1 Damien Miller 2008-12-08 09:57:22 AEDT
Is the substitution "${1%:}" supported in the standard Bourne shell?
Comment 2 Colin Watson 2008-12-08 10:37:22 AEDT
It's not a bashism at any rate, being in POSIX (http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02).

I suspect that it is unfortunately not portable to Solaris' anaemic shell. I usually program to POSIX shell where I can, but if ssh-copy-id needs to work on Solaris then I concede that that might be a problem and that it'll need to use command substitution and sed instead.
Comment 3 Darren Tucker 2010-08-03 16:12:48 AEST
You're right, solaris' /bin/sh doesn't support it:

# a=foo:
# echo ${a%:}
bad substitution
# uname -rs
SunOS 5.8

This, although uglier, works:
host=`echo $1 | sed 's/:$//':`
Comment 4 Darren Tucker 2010-08-03 16:21:15 AEST
Created attachment 1909 [details]
openssh-ssh-copy-id.patch

Strip trailing colon from hostname.
Comment 5 Darren Tucker 2010-08-03 16:22:31 AEST
BTW solaris' /bin/sh doesn't do tilde expansion either, so it'll not work as a target right now.
Comment 6 Darren Tucker 2010-08-10 13:37:09 AEST
applied, will be in the 5.6p1 release.

Thanks.
Comment 7 Darren Tucker 2010-08-27 10:28:12 AEST
With the release of OpenSSH 5.6p1 this bug is now considered closed.  If you have further problems please reopen or file a new bug as appropriate.