Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I routinely run sshd on a non-standard port (ie, not 22).

When ssh-ing to my machine I use the -p flag. However, when using scp, the flag is -P (lowercase vs uppercase).

Since they come out of the same suite, why would then not use the same flag capitalization? Is it really just because two different folks wrote it? Neither uses the other form of "p" for anything - wouldn't it make sense for them to work identically*?


*I know - I could modify the source and have a package that accepted both forms: but that does not solve the upstream issue, nor would I expect my patch submission to ever make it into the trunk code (though I'll be giving it a shot).

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

My guess... and this is only a guess... is that -p was already used by rcp for the current meaning of "Preserves modification times, access times, and modes from the original file." And since scp was written to be a drop-in secure replacement for rcp, it was important to honor that flag as rcp understood it. This meant that the option of using a non-standard port had to use another flag.

EDIT: Possible wrapper to convert -P to -p for ssh. It should handle the common cases, but it's not thoroughly tested. To handle even the strangest cases, something that does proper command-line interpretation (such as perl's Getopt modules) would be better.

#!/bin/bash

for x in "$@"; do
    if [ "$END"x == "x" ]; then
        case $x in
            "-P") x="-p" ;;
            "--") END=1 ;;
        esac
    fi
    ARGS="$ARGS $x"
done

ssh $ARGS
share|improve this answer
1  
Indeed, rcp uses -p for “preserve metadata”, and it does so to imitate cp. –  Gilles Jun 19 '11 at 9:54
    
that sure sounds plausible –  warren Jun 20 '11 at 4:05
    
though - then the question would still remain, why not use -P for ssh as well? –  warren Jun 20 '11 at 4:10
    
I think ssh existed before scp... so there would have been no reason to use -P instead of -p. But that observation brings up a simple point... it would be trivial to write a ssh wrapper that converted -P to -p, so that you could use -P both places. No need to hack the ssh source and recompile that way. –  Flimzy Jun 20 '11 at 4:12
1  
I updated my answer with one such possible wrapper. –  Flimzy Jul 6 '11 at 14:53
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.