metadex/scripts/ls
2022-08-14 20:41:58 +02:00

23 lines
544 B
Bash
Executable file

#!/bin/sh -eu
# Create a `ingest-ls` compatible file listing.
#
# Compatible with current versions of GNU and macOS `ls`.
#
# $ scripts/ls -R /some/base/path \
# | python -m metadex ingest-ls --remove-missing
_ls() {
if command ls -d --time-style='+%s' . >/dev/null 2>&1; then
# echo 'GNU'
command ls --time-style='+%s' "$@"
elif command ls -d -D '%s' . >/dev/null 2>&1; then
# echo 'macOS'
command ls -D '%s' "$@"
else
# echo 'unknown'
command ls "$@"
fi
}
_ls -lnAU "$@"