- djm@cvs.openbsd.org 2004/06/22 01:16:39

[sftp.c]
     don't show .files by default in ls, add -a option to turn them back on;
     ok markus
This commit is contained in:
Darren Tucker 2004-06-22 13:09:55 +10:00
parent 15ca6e8842
commit 9a52645566
2 changed files with 17 additions and 4 deletions

View File

@ -33,6 +33,10 @@
- djm@cvs.openbsd.org 2004/06/21 22:41:31 - djm@cvs.openbsd.org 2004/06/21 22:41:31
[sftp.1] [sftp.1]
document sort options document sort options
- djm@cvs.openbsd.org 2004/06/22 01:16:39
[sftp.c]
don't show .files by default in ls, add -a option to turn them back on;
ok markus
20040620 20040620
- (tim) [configure.ac Makefile.in] Only change TEST_SHELL on broken platforms. - (tim) [configure.ac Makefile.in] Only change TEST_SHELL on broken platforms.
@ -1355,4 +1359,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
$Id: ChangeLog,v 1.3426 2004/06/22 03:08:21 dtucker Exp $ $Id: ChangeLog,v 1.3427 2004/06/22 03:09:55 dtucker Exp $

15
sftp.c
View File

@ -16,7 +16,7 @@
#include "includes.h" #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 "buffer.h" #include "buffer.h"
#include "xmalloc.h" #include "xmalloc.h"
@ -72,6 +72,7 @@ char *__progname;
#define LS_TIME_SORT 0x10 /* Sort by mtime */ #define LS_TIME_SORT 0x10 /* Sort by mtime */
#define LS_SIZE_SORT 0x20 /* Sort by file size */ #define LS_SIZE_SORT 0x20 /* Sort by file size */
#define LS_REVERSE_SORT 0x40 /* Reverse sort order */ #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 VIEW_FLAGS (LS_LONG_VIEW|LS_SHORT_VIEW|LS_NUMERIC_VIEW)
#define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT) #define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT)
@ -378,6 +379,9 @@ parse_ls_flags(const char **cpp, int *lflag)
case 'f': case 'f':
*lflag &= ~SORT_FLAGS; *lflag &= ~SORT_FLAGS;
break; break;
case 'a':
*lflag |= LS_SHOW_ALL;
break;
default: default:
error("Invalid flag -%c", *cp); error("Invalid flag -%c", *cp);
return(-1); return(-1);
@ -666,8 +670,10 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
char *tmp; char *tmp;
/* Count entries for sort and find longest filename */ /* Count entries for sort and find longest filename */
for (n = 0; d[n] != NULL; n++) for (n = 0; d[n] != NULL; n++) {
m = MAX(m, strlen(d[n]->filename)); 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 */ /* Add any subpath that also needs to be counted */
tmp = path_strip(path, strip_path); tmp = path_strip(path, strip_path);
@ -691,6 +697,9 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
for (n = 0; d[n] != NULL && !interrupted; n++) { for (n = 0; d[n] != NULL && !interrupted; n++) {
char *tmp, *fname; char *tmp, *fname;
if (d[n]->filename[0] == '.' && !(lflag & LS_SHOW_ALL))
continue;
tmp = path_append(path, d[n]->filename); tmp = path_append(path, d[n]->filename);
fname = path_strip(tmp, strip_path); fname = path_strip(tmp, strip_path);
xfree(tmp); xfree(tmp);