Anshul Nigham wrote: > I don't think this could be intended or expected behavior in any > scenario. I suggest that the cp behavior be modified to look for a > destination file operand before expanding wildcards, in which case a > command like "cp [options] wildcard-expr" would still exit with an > error of missing destination file operand, even if the wildcard-expr > expands to two or more files.
You have a misconception as to how globbing works. It is not done by 'cp' at all, it is entirely the domain of the shell. By the time 'cp' looks at its arguments, they are already expanded and 'cp' has no way to differentiate whether the user specified "*.txt" or "a.txt b.txt". You can trivially verify this yourself with a 5 line C program that just prints the contents of 'argv[]'. This is by design. The original intent of unix was along the lines of "a lot of small programs, each that do one thing really well." In that vein, the shell does all globbing (and variable expansion/substitution, quoting, etc.) for all program invocations, rather than having to add glob expansion code to every little individual program that might ever need to process more than one file. Brian _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
