Support THC secure-delete

Recent Linux distribution uses newer THC secure-delete and
it only supports few options.
This commit is contained in:
Shohei YOSHIDA 2023-10-03 20:05:59 +09:00
parent 5e6f4da967
commit 41e7188db5
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 42 additions and 18 deletions

View File

@ -36,8 +36,25 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
local -a opts args local -a args
args=( args=(
'*::files:->file'
)
_pick_variant -r variant gnu=gnu thc=THC unix --help
if [[ $variant == "thc" ]]; then
args+=(
'-d[ignore the two special dot files . and .. on the commandline]'
'-f[fast (and insecure mode)]'
'*-l[lessens the security. -l for a second time lessons the security even more]'
'-r[recursive mode]'
'-v[verbose mode]'
'-z[wipes the last write with zeros instead of random data]'
)
else
args+=(
'(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]' '(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]'
'(-r --interactive)'{-i,--interactive}'[prompt before any removal]' '(-r --interactive)'{-i,--interactive}'[prompt before any removal]'
'(-r -R --recursive)'{-r,-R,--recursive}'[remove the contents of directories recursively]' '(-r -R --recursive)'{-r,-R,--recursive}'[remove the contents of directories recursively]'
@ -45,10 +62,9 @@ args=(
'(-v --verbose)'{-v,--verbose}'[explain what is being done]' '(-v --verbose)'{-v,--verbose}'[explain what is being done]'
'(- *)--help[display help message and exit]' '(- *)--help[display help message and exit]'
'(- *)--version[output version information and exit]' '(- *)--version[output version information and exit]'
'*::files:->file'
) )
if _pick_variant gnu=gnu unix --help; then if [[ $variant == "gnu" ]]; then
args+=( args+=(
'(-x --one-file-system)'{-x,--one-file-system}'[stay within filesystems of files given as arguments]' '(-x --one-file-system)'{-x,--one-file-system}'[stay within filesystems of files given as arguments]'
'(-P --openbsd)'{-P,--openbsd}'[overwrite the file 3 times (0xff, 0x00, 0xff)]' '(-P --openbsd)'{-P,--openbsd}'[overwrite the file 3 times (0xff, 0x00, 0xff)]'
@ -62,12 +78,12 @@ else
'(-n --nounlink)'{-n,--nounlink}'[overwrite file, but do not rename or unlink it]' '(-n --nounlink)'{-n,--nounlink}'[overwrite file, but do not rename or unlink it]'
) )
fi fi
fi
local curcontext=$curcontext state line ret=1 local curcontext=$curcontext state line ret=1
local -A opt_args local -A opt_args
_arguments -s -S -C $opts \ _arguments -s -S -C $args && ret=0
$args && ret=0
case $state in case $state in
(file) (file)
@ -82,3 +98,11 @@ case $state in
esac esac
return $ret return $ret
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et