| Summary: | Inconsistend wildcard expansion in 'ls *' | ||
|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | Grigory <gtrenin> |
| Component: | sftp | Assignee: | Assigned to nobody <unassigned-bugs> |
| Status: | NEW --- | ||
| Severity: | normal | CC: | djm |
| Priority: | P2 | ||
| Version: | 5.5p1 | ||
| Hardware: | All | ||
| OS: | All | ||
|
Description
Grigory
2010-05-05 23:13:03 AEST
This is the special case code:
755 /*
756 * If the glob returns a single match and it is a directory,
757 * then just list its contents.
758 */
759 if (g.gl_matchc == 1) {
760 if ((a = do_lstat(conn, g.gl_pathv[0], 1)) == NULL) {
761 globfree(&g);
762 return (-1);
763 }
764 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&
765 S_ISDIR(a->perm)) {
766 int err;
767
768 err = do_ls_dir(conn, g.gl_pathv[0], strip_path,
lflag);
769 globfree(&g);
770 return (err);
771 }
772 }
Arguably, the special case behaviour is more consistent with a normal shell when executing "ls *"
This behaviour is confusing for scripts that invoke sftp in batch mode. "ls -1 *" is a convenient way for a script to differ directories from files because directories are marked by '/' in the end of them. |