Live data from Hacker News

I always forget the argument order of the `ln -s` command

reddit.com

11–20 of 127 posts

Re: I always forget the argument order of the `ln -s` command

#12
post #10

Does anyone know why C calls like 'strcpy' and 'strcat' are the opposite of this? strcat(target, source) strcpy(target, source) But, in SH... cp source target I feel like these things were developed around the same time, by the same community. I've always wondered if there was a reason for the different perspective.

I suspect strcat and strcpy were parameterized as such to match memcpy.

Why memcpy was parameterized in that order, I am not certain.

Re: I always forget the argument order of the `ln -s` command

#14
post #10

Does anyone know why C calls like 'strcpy' and 'strcat' are the opposite of this? strcat(target, source) strcpy(target, source) But, in SH... cp source target I feel like these things were developed around the same time, by the same community. I've always wondered if there was a reason for the different perspective.

Probably in order to be consistent with assignment.

Re: I always forget the argument order of the `ln -s` command

#15
post #8

My god, this thing always keeps biting me. It seems so obvious now with that cp-mnemonic. But it makes me wonder, why does everyone do it wrong in the first place?

At least for me, it's because I say in my head "link $FOO to $BAR", which must be typed "ln -s $BAR $FOO".

Re: I always forget the argument order of the `ln -s` command

#19
post #10

Does anyone know why C calls like 'strcpy' and 'strcat' are the opposite of this? strcat(target, source) strcpy(target, source) But, in SH... cp source target I feel like these things were developed around the same time, by the same community. I've always wondered if there was a reason for the different perspective.

Possibly for consistency with functions that take varargs, e.g. sprintf

Re: I always forget the argument order of the `ln -s` command

#20
post #16

I've always used complex numbers as a mnemonic: real + imaginary, a + bi (obviously the file is real and the softlink is "imaginary"). http://en.wikipedia.org/wiki/Complex_number

The real/imaginary concept is exactly what I use too. I sort of recall being able to use the real/imaginary concept with other Unix commands as well, but I can't recall which ones off the top of my head.
Post reply on HN