summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2004-06-20 18:53:40 +0000
committerDamien Miller <djm@cvs.openbsd.org>2004-06-20 18:53:40 +0000
commit72951f25abbdf39776b532d4017546c7077ff21b (patch)
treeb1a0e873fbacd5b5ad3066d60969d30d61311d7f /usr.bin
parent8908ae08ec12426bf0c946b2bb67e4b6a8825518 (diff)
make "ls -l" listings print user/group names, add "ls -n" to show uid/gid
(like /bin/ls); idea & ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sftp.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index dfce3090f53..167c009bc97 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.49 2004/06/18 06:13:25 dtucker Exp $");
+RCSID("$OpenBSD: sftp.c,v 1.50 2004/06/20 18:53:39 djm Exp $");
#include <glob.h>
@@ -57,9 +57,11 @@ int remote_glob(struct sftp_conn *, const char *, int,
/* Separators for interactive commands */
#define WHITESPACE " \t\r\n"
-/* Define what type of ls view (0 - multi-column) */
-#define LONG_VIEW 1 /* Full view ala ls -l */
-#define SHORT_VIEW 2 /* Single row view ala ls -1 */
+/* Define what type of ls view */
+#define LONG_VIEW 1 /* Full view ala ls -l */
+#define SHORT_VIEW 2 /* Single row view ala ls -1 */
+#define NUMERIC_VIEW 4 /* Long view with numeric uid/gid */
+#define VIEW_FLAGS (LONG_VIEW|SHORT_VIEW|NUMERIC_VIEW)
/* Commands for interactive mode */
#define I_CHDIR 1
@@ -335,10 +337,16 @@ parse_ls_flags(const char **cpp, int *lflag)
for(; strchr(WHITESPACE, *cp) == NULL; cp++) {
switch (*cp) {
case 'l':
- *lflag = LONG_VIEW;
+ *lflag &= ~VIEW_FLAGS;
+ *lflag |= LONG_VIEW;
break;
case '1':
- *lflag = SHORT_VIEW;
+ *lflag &= ~VIEW_FLAGS;
+ *lflag |= SHORT_VIEW;
+ break;
+ case 'n':
+ *lflag &= ~VIEW_FLAGS;
+ *lflag |= NUMERIC_VIEW|LONG_VIEW;
break;
default:
error("Invalid flag -%c", *cp);
@@ -646,14 +654,17 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
xfree(tmp);
if (lflag & LONG_VIEW) {
- char *lname;
- struct stat sb;
-
- memset(&sb, 0, sizeof(sb));
- attrib_to_stat(&d[n]->a, &sb);
- lname = ls_file(fname, &sb, 1);
- printf("%s\n", lname);
- xfree(lname);
+ if (lflag & NUMERIC_VIEW) {
+ char *lname;
+ struct stat sb;
+
+ memset(&sb, 0, sizeof(sb));
+ attrib_to_stat(&d[n]->a, &sb);
+ lname = ls_file(fname, &sb, 1);
+ printf("%s\n", lname);
+ xfree(lname);
+ } else
+ printf("%s\n", d[n]->longname);
} else {
printf("%-*s", colspace, fname);
if (c >= columns) {