-A, \--almost-all
: show hidden files, except "." and "..".
+-d, \--directory
+: show information about directories themselves, rather than their
+ contents, and don't follow symlinks.
+
-l
: provide a detailed, long listing for each item.
"""Common code for listing files from a bup repository."""
-import copy, stat, xstat
+import copy, os.path, stat, xstat
from bup import metadata, options, vfs
from helpers import *
a,all show hidden files
A,almost-all show hidden files except . and ..
l use a detailed, long listing format
+d,directory show directories, not contents; don't follow symlinks
F,classify append type indicator: dir/ sym@ fifo| sock= exec*
file-type append type indicator: dir/ sym@ fifo| sock=
human-readable print human readable file sizes (i.e. 3.9K, 4.7M)
ret = 0
for path in (extra or [default]):
try:
- n = pwd.try_resolve(path)
+ if opt.directory:
+ n = pwd.lresolve(path)
+ else:
+ n = pwd.try_resolve(path)
- if stat.S_ISDIR(n.mode):
+ if not opt.directory and stat.S_ISDIR(n.mode):
if show_hidden == 'all':
output_node_info(n, '.')
# Match non-bup "ls -a ... /".
or not len(name)>1 or not name.startswith('.'):
output_node_info(sub, name)
else:
- output_node_info(n, path)
+ output_node_info(n, os.path.normpath(path))
except vfs.NodeError, e:
log('error: %s\n' % e)
ret = 1
WVPASS bup index src
WVPASS bup save -n src src
+
WVSTART "ls (short)"
WVPASSEQ "$(WVPASS bup ls /)" "src"
socket=
symlink@"
+WVPASSEQ "$(WVPASS bup ls -d src/latest/"$tmpdir"/src)" "src/latest$tmpdir/src"
+
+
WVSTART "ls (long)"
WVPASSEQ "$(WVPASS bup ls -l / | tr -s ' ' ' ')" \
srwx------ $uid/$gid 0 1969-07-20 20:18 socket
$symlink_mode $uid/$gid $symlink_size $symlink_date symlink -> file"
+WVPASSEQ "$(bup ls -ld "src/latest$tmpdir/src" | tr -s ' ' ' ')" \
+"drwx------ $user/$group 0 1969-07-20 20:18 src/latest$tmpdir/src"
+
+
WVSTART "ls (backup set - long)"
WVPASSEQ "$(bup ls -l src | cut -d' ' -f 1-2)" \
"l--------- ?/?
l--------- ?/?"
+
WVSTART "ls (dates TZ != UTC)"
export TZ=US/Central
symlink_date_central="$(bup ls -l src/latest"$tmpdir"/src | grep symlink)"
$symlink_mode $uid/$gid $symlink_size $symlink_date_central symlink -> file"
unset TZ
+
WVPASS rm -rf "$tmpdir"