Well, I think all involved parties made clear what their position on that matter is. I hope no hard feelings remain.
That said, "behave like GNU ls" as an explicit goal is a good idea regardless. With that in mind, I just hacked together exactly that, see attached patch. Uli
diff -upwr tree-1.5.3.orig/man/tree.1 tree-1.5.3/man/tree.1 --- tree-1.5.3.orig/man/tree.1 2009-12-31 15:54:48.000000000 +0100 +++ tree-1.5.3/man/tree.1 2009-12-31 16:27:24.000000000 +0100 @@ -115,7 +115,13 @@ Print the size of each file in bytes alo .B -h Print the size of each file but in a more human readable way, e.g. appending a size letter for kilobytes (K), megabytes (M), gigabytes (G), terrabytes (T), -petabytes (P) and exabytes (E). +petabytes (P) and exabytes (E). These are similar to how 'ls' works, i.e. using +a base of 1024. +.PP +.TP +.B --si +Like '-h', print the size of each file in a more human readable way, but using +SI prefixes and a base of 1000. .PP .TP .B -u @@ -131,16 +137,16 @@ Print the date of the last modification .PP .TP .B --inodes -Prints the inode number of the file or directory +Prints the inode number of the file or directory. .PP .TP .B --device -Prints the device number to which the file or directory belongs +Prints the device number to which the file or directory belongs. .PP .TP .B -F Append a `/' for directories, a `=' for socket files, a `*' for executable files -and a `|' for FIFO's, as per ls -F +and a `|' for FIFO's, as per ls -F. .PP .TP .B -q Only in tree-1.5.3.orig: strverscmp.c.orig Only in tree-1.5.3: tree diff -upwr tree-1.5.3.orig/tree.c tree-1.5.3/tree.c --- tree-1.5.3.orig/tree.c 2009-12-31 15:54:48.000000000 +0100 +++ tree-1.5.3/tree.c 2009-12-31 16:08:24.000000000 +0100 @@ -182,7 +182,7 @@ int strverscmp (const char *s1, const ch /* Globals */ int dflag, lflag, pflag, sflag, Fflag, aflag, fflag, uflag, gflag; -int qflag, Nflag, Dflag, inodeflag, devflag, hflag; +int qflag, Nflag, Dflag, inodeflag, devflag, hflag, siflag; int noindent, force_color, nocolor, xdev, noreport, nolinks, flimit; char *pattern = NULL, *ipattern = NULL, *host = NULL, *title = "Directory Tree", *sp = " "; const char *charset=NULL; @@ -206,7 +206,7 @@ int main(int argc, char **argv) q = p = dtotal = ftotal = 0; aflag = dflag = fflag = lflag = pflag = sflag = Fflag = uflag = gflag = FALSE; - Dflag = qflag = Nflag = Hflag = Rflag = hflag = FALSE; + Dflag = qflag = Nflag = Hflag = Rflag = hflag = siflag = FALSE; noindent = force_color = nocolor = xdev = noreport = nolinks = FALSE; inodeflag = devflag = FALSE; flimit = 0; @@ -390,6 +390,12 @@ int main(int argc, char **argv) cmpfunc = dirsfirstsort; break; } + if (!strcmp("--si",argv[i])) { + j = strlen(argv[i])-1; + siflag = TRUE; + sflag = TRUE; /* Assume they also want -s */ + break; + } if (!strncmp("--filelimit",argv[i],11)) { j = 11; if (*(argv[i]+11) == '=') { @@ -1293,14 +1299,18 @@ void printit(char *s) void psize(char *buf, off_t size) { char *unit="BKMGTPEZY"; + char *si_unit=" kMGTPEZY"; int idx; - if (!hflag) sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9ld", size); - else { + if (hflag) { for (idx=size<1024?0:1; size >= (1024*1024); idx++,size>>=10); if (!idx) sprintf(buf, " %4d", (int)size); else sprintf(buf, ((size>>10) >= 10)? " %3.0f%c" : " %3.1f%c", (float)size/(float)1024,unit[idx]); - } + } else if (siflag) { + for (idx=size<1000?0:1; size >= (1000000); idx++,size/=1000); + if (!idx) sprintf(buf, " %4d", (int)size); + else sprintf(buf, (size >= 10000)? " %3.0f%c" : " %3.1f%c", (float)size/1000.0f,si_unit[idx]); + } else sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9ld", size); } void html_encode(FILE *fd, char *s) Only in tree-1.5.3: tree.c~ Only in tree-1.5.3: tree.o