#!/bin/bash [ -f testing.sh ] && . testing.sh #testing "name" "command" "result" "infile" "stdin" # We don't know whether the fs will have extents (e, typically true on the # desktop) or be encrypted (E, typically true on Android), so ask. # Unfortunately, this requires that we trust lsattr... mkdir dir && cd dir && touch file _b=$(lsattr -d . | awk '{print $1}') _A=$(lsattr file | sed 's/^--------/-------A/' | awk '{print $1}') attrs="No_Atime" lsattr -d . | grep -q e && attrs="$attrs, Extents" lsattr -d . | grep -q E && attrs="$attrs, Encrypted" chattr +A file &>/dev/null testing "file" "lsattr file" "$_A file\n" "" "" testing "-R file" "lsattr -R file" "$_A file\n" "" "" testing "-a file" "lsattr -a file" "$_A file\n" "" "" testing "-d ." "lsattr -d ." "$_b .\n" "" "" testing "-d file" "lsattr -d file" "$_A file\n" "" "" NOSPACE=1 testing "-l file" "lsattr -l file" "file $attrs\n" "" "" NOSPACE=1 testing "-v file" "lsattr -v file | sed 's/^[0-9]*/_/'" \ "_ $_A file\n" "" "" NOSPACE=1 testing "-lv file" "lsattr -lv file | sed 's/^[0-9]*/_/'" \ "_ file $attrs\n" "" "" chattr -AacDdijsStTu file && cd .. rm -rf dir