]> andersk Git - openssh.git/blobdiff - sftp.c
- deraadt@cvs.openbsd.org 2004/07/11 17:48:47
[openssh.git] / sftp.c
diff --git a/sftp.c b/sftp.c
index 37adb0286894ae7c0c4d3e784680e0e8a9e64a27..f01c9194c3642df3bdc8c74667cc9e8e942cf9cd 100644 (file)
--- a/sftp.c
+++ b/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.56 2004/07/11 17:48:47 deraadt Exp $");
 
 #include "buffer.h"
 #include "xmalloc.h"
@@ -55,11 +55,7 @@ int sort_flag;
 int remote_glob(struct sftp_conn *, const char *, int,
     int (*)(const char *, int), glob_t *); /* proto for sftp-glob.c */
 
-#ifdef HAVE___PROGNAME
 extern char *__progname;
-#else
-char *__progname;
-#endif
 
 /* Separators for interactive commands */
 #define WHITESPACE " \t\r\n"
@@ -72,6 +68,7 @@ char *__progname;
 #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)
@@ -378,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);
@@ -424,7 +424,7 @@ get_pathname(const char **cpp, char **path)
                                i++;
                                if (cp[i] != '\'' && cp[i] != '\"' &&
                                    cp[i] != '\\') {
-                                       error("Bad escaped character '\%c'",
+                                       error("Bad escaped character '\\%c'",
                                            cp[i]);
                                        goto fail;
                                }
@@ -666,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);
@@ -691,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);
@@ -1323,8 +1328,8 @@ connect_to_server(char *path, char **args, int *in, int *out)
 
                /*
                 * The underlying ssh is in the same process group, so we must
-                * ignore SIGINT if we want to gracefully abort commands, 
-                * otherwise the signal will make it to the ssh process and 
+                * ignore SIGINT if we want to gracefully abort commands,
+                * otherwise the signal will make it to the ssh process and
                 * kill it too
                 */
                signal(SIGINT, SIG_IGN);
@@ -1410,7 +1415,7 @@ main(int argc, char **argv)
                                fatal("Batch file already specified.");
 
                        /* Allow "-" as stdin */
-                       if (strcmp(optarg, "-") != 0 && 
+                       if (strcmp(optarg, "-") != 0 &&
                           (infile = fopen(optarg, "r")) == NULL)
                                fatal("%s (%s).", strerror(errno), optarg);
                        showprogress = 0;
This page took 0.038489 seconds and 4 git commands to generate.