*
* See http://opengroup.org/onlinepubs/9699919799/utilities/ls.html
-USE_LS(NEWTOY(ls, USE_LS_COLOR("(color):;")"(show-control-chars)ZgoACFHLRSabcdfhiklmnpqrstux1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][!qb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, USE_LS_COLOR("(color):;")"(full-time)(show-control-chars)ZgoACFHLRSabcdfhikl@mnpqrstux1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][!qb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
config LS
bool "ls"
-g like -l but no owner -h human readable sizes
-l long (show full details) -m comma separated
-n like -l but numeric uid/gid -o like -l but no group
- -x columns (horizontal sort)
+ -x columns (horizontal sort) -ll long with nanoseconds (--full-time)
sorting (default is alphabetical):
-f unsorted -r reverse -t timestamp -S size
// ls -lR starts .: then ./subdir:
GLOBALS(
+ long ll;
char *color;
struct dirtree *files, *singledir;
len[1] = (flags & FLAG_i) ? numlen(st->st_ino) : 0;
if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) {
unsigned fn = flags & FLAG_n;
+
len[2] = numlen(st->st_nlink);
len[3] = fn ? numlen(st->st_uid) : strwidth(getusername(st->st_uid));
len[4] = fn ? numlen(st->st_gid) : strwidth(getgroupname(st->st_gid));
struct dirtree *dt, **sort;
unsigned long dtlen, ul = 0;
unsigned width, flags = toys.optflags, totals[8], len[8], totpad = 0,
- *colsizes = (unsigned *)(toybuf+260), columns = (sizeof(toybuf)-260)/4;
+ *colsizes = (unsigned *)toybuf, columns = sizeof(toybuf)/4;
char tmp[64];
if (-1 == dirfd) {
// print time, always in --time-style=long-iso
tm = localtime(&(st->st_mtime));
strftime(tmp, sizeof(tmp), "%F %H:%M", tm);
+ if (TT.ll>1) {
+ char *s = tmp+strlen(tmp);
+
+ s += sprintf(s, ":%02d.%09d ", tm->tm_sec, (int)st->st_mtim.tv_nsec);
+ strftime(s, sizeof(tmp)-(s-tmp), "%z", tm);
+ }
printf(" %s ", tmp);
} else if (flags & FLAG_Z)
printf("%-*s ", (int)totals[7], (char *)sort[next]->extra);
char **s, *noargs[] = {".", 0};
struct dirtree *dt;
+ if (toys.optflags&FLAG_full_time) {
+ toys.optflags |= FLAG_l;
+ TT.ll = 2;
+ }
+
// Do we have an implied -1
if (isatty(1)) {
if (!(toys.optflags&FLAG_show_control_chars)) toys.optflags |= FLAG_b;