summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2004-06-22 01:16:40 +0000
committerDamien Miller <djm@cvs.openbsd.org>2004-06-22 01:16:40 +0000
commit02a7c0805e8a7a257c55e031889f3dd3c5794614 (patch)
tree6e257b321f647159bf93d4974122b21a351f93c1 /usr.bin/ssh
parent924161f5d45884bdeafceddc3ae7d19afdb1e599 (diff)
don't show .files by default in ls, add -a option to turn them back on;
ok markus
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/sftp.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index 670b7817de2..bec4cbee1f8 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -16,7 +16,7 @@
#include "includes.h"
-RCSID("$OpenBSD: sftp.c,v 1.53 2004/06/21 22:30:45 djm Exp $");
+RCSID("$OpenBSD: sftp.c,v 1.54 2004/06/22 01:16:39 djm Exp $");
#include <glob.h>
@@ -68,6 +68,7 @@ int remote_glob(struct sftp_conn *, const char *, int,
#define LS_TIME_SORT 0x10 /* Sort by mtime */
#define LS_SIZE_SORT 0x20 /* Sort by file size */
#define LS_REVERSE_SORT 0x40 /* Reverse sort order */
+#define LS_SHOW_ALL 0x80 /* Don't skip filenames starting with '.' */
#define VIEW_FLAGS (LS_LONG_VIEW|LS_SHORT_VIEW|LS_NUMERIC_VIEW)
#define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT)
@@ -374,6 +375,9 @@ parse_ls_flags(const char **cpp, int *lflag)
case 'f':
*lflag &= ~SORT_FLAGS;
break;
+ case 'a':
+ *lflag |= LS_SHOW_ALL;
+ break;
default:
error("Invalid flag -%c", *cp);
return(-1);
@@ -662,8 +666,10 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
char *tmp;
/* Count entries for sort and find longest filename */
- for (n = 0; d[n] != NULL; n++)
- m = MAX(m, strlen(d[n]->filename));
+ for (n = 0; d[n] != NULL; n++) {
+ if (d[n]->filename[0] != '.' || (lflag & LS_SHOW_ALL))
+ m = MAX(m, strlen(d[n]->filename));
+ }
/* Add any subpath that also needs to be counted */
tmp = path_strip(path, strip_path);
@@ -687,6 +693,9 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
for (n = 0; d[n] != NULL && !interrupted; n++) {
char *tmp, *fname;
+ if (d[n]->filename[0] == '.' && !(lflag & LS_SHOW_ALL))
+ continue;
+
tmp = path_append(path, d[n]->filename);
fname = path_strip(tmp, strip_path);
xfree(tmp);