exec expect
-- "$0" ${1+"$@"}
# Author: Don Libes, NIST
# Encrypt or decrypts the current directory or named directory if given.
if {[llength
$argv] > 0} {
set decrypt
[regexp
"decrypt" $argv0]
set passwd
$expect_out(1,string
)
# Wouldn't want to encrypt/decrypt files with mistyped password!
if {![string match
$passwd $expect_out(1,string
)]} {
send_user
"mistyped password?\n"
# strip shell metachars from filename to avoid problems
if {[regsub
-all {[]['`~<>:-]} $f "" newf]} {
set strcmp [string compare .crypt [file extension $f]]
# skip files that don't end with
".crypt"
spawn sh
-c "exec crypt < $f > [file root $f]"
# skip files that already end with ".crypt"
spawn sh
-c "exec crypt < $f > $f.crypt"