substituted echo with print in code

this will avoid spawning an extra echo process each time
print is a zsh builtin, an alternative to the use of <<< suggested by anathema
This commit is contained in:
Jaromil 2011-05-09 11:00:47 +02:00
parent 052549a4f9
commit cb9a6bf730

View File

@ -92,8 +92,8 @@ safe_dir() {
return return
fi fi
dir="/dev/shm/$1.$RANDOM.$RANDOM.$$" dir="/dev/shm/$1.$RANDOM.$RANDOM.$$"
(umask 077 && mkdir "$dir") || echo "-1" (umask 077 && mkdir "$dir") || print "-1"
echo "$dir" print "$dir"
} }
# we use pinentry now # we use pinentry now
@ -220,8 +220,14 @@ Commands:
list list all open tombs or the one called FILE list list all open tombs or the one called FILE
close close the open tomb called FILE (or all) close close the open tomb called FILE (or all)
slam close tomb FILE and kill all pids using it slam close tomb FILE and kill all pids using it
EOF
if [ "$STEGHIDE" = 1 ]; then
cat <<EOF
bury hide a tomb key FILE inside a jpeg PLACE bury hide a tomb key FILE inside a jpeg PLACE
exhume extract a tomb key FILE from a jpeg PLACE exhume extract a tomb key FILE from a jpeg PL
EOF
fi
cat <<EOF
Options: Options:
@ -346,7 +352,7 @@ create_tomb() {
fi fi
echo "${tombpass}" | gpg \ print "${tombpass}" | gpg \
--openpgp --batch --no-options --no-tty --passphrase-fd 0 2>/dev/null \ --openpgp --batch --no-options --no-tty --passphrase-fd 0 2>/dev/null \
-o "${tombdir}/${tombname}.tomb.key" -c -a ${keytmp}/tomb.tmp -o "${tombdir}/${tombname}.tomb.key" -c -a ${keytmp}/tomb.tmp
@ -455,7 +461,7 @@ mount_tomb() {
else else
tombpass=`exec_as_user ${TOMBEXEC} askpass "$keyname (retry $c)"` tombpass=`exec_as_user ${TOMBEXEC} askpass "$keyname (retry $c)"`
fi fi
echo "${tombpass}" \ print "${tombpass}" \
| gpg --batch --passphrase-fd 0 --no-tty --no-options \ | gpg --batch --passphrase-fd 0 --no-tty --no-options \
-d "${tombkey}" 2> /dev/null \ -d "${tombkey}" 2> /dev/null \
| cryptsetup --key-file - luksOpen ${nstloop} ${mapper} | cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
@ -693,7 +699,7 @@ umount_tomb() {
if [ "${pathmap}" = "/dev/mapper" ]; then if [ "${pathmap}" = "/dev/mapper" ]; then
mapper="$1" # argument is the mapper (or none which autofills mapper) mapper="$1" # argument is the mapper (or none which autofills mapper)
tombname="`echo $mapper | cut -d. -f2`" tombname="`print $mapper | cut -d. -f2`"
tombmount=`mount -l | \ tombmount=`mount -l | \
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $3 } '` awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $3 } '`
@ -709,7 +715,7 @@ umount_tomb() {
tombmount="$1" # argument should be the mount tombmount="$1" # argument should be the mount
mapper=`mount | awk -vmnt="$tombmount" '/^\/dev\/mapper\/tomb/ { if($3==mnt) print $1 }'` mapper=`mount | awk -vmnt="$tombmount" '/^\/dev\/mapper\/tomb/ { if($3==mnt) print $1 }'`
tombname="`echo $mapper | cut -d. -f2`" tombname="`print $mapper | cut -d. -f2`"
fi fi
@ -941,7 +947,7 @@ EOF
} }
main () { main () {
echo $@ | grep '\-D' 2>&1 > /dev/null print $@ | grep '\-D' 2>&1 > /dev/null
# ????? # ?????
if [ $? = 0 ]; then if [ $? = 0 ]; then
fi fi
@ -965,8 +971,8 @@ main () {
exit 0 ;; exit 0 ;;
-q) QUIET=1; shift 1 ;; -q) QUIET=1; shift 1 ;;
-D) -D)
echo "[D] Tomb invoked with args \"${(f)@}\" " print "[D] Tomb invoked with args \"${(f)@}\" "
echo "[D] running on `date`" print "[D] running on `date`"
DEBUG=1; shift 1 ;; DEBUG=1; shift 1 ;;
-s) SIZE=$2; shift 2 ;; -s) SIZE=$2; shift 2 ;;
-k) KEY=$2; shift 2 ;; -k) KEY=$2; shift 2 ;;