On Sun, 2014-06-15 at 01:46 -0400, david...@ling.ohio-state.edu wrote: > > echo "${SHUTDOWNBODY}" | mail -s "${SHUTDOWNSUBJECT}" ${EMAIL} > > sleep 4 > > RETVAL=$? > > i can't comment on the rest of the script, but you probably want > RETVAL to be the exit status of the pipeline that sends the mail. > making RETVAL the exit status of 'sleep 4' looks wrong to me.
Compliment for the heads up :). Indeed, it's unlikely that somebody wants to know the exit status of a sleep command and also unlikely that a sleep command will exit with another status than 0. I could imagine that there is a problem. While processing mail -s there might be a delay, but the script perhaps continues, so the OP perhaps got the exit status of echo, since mail -s didn't finish. Maybe a && is what this problem could solve. I experienced issues where I wanted to run a command and wait until the command finished before I run the next command, without the need to get the exit status, but && or a PS aux loop doesn't work always. It e.g. often fails here: $ cat /usr/local/bin/evowrap #!/bin/sh case $1 in JWM) evoterm --force-shutdown while ps aux | grep "evowrap --force-shutdown" | grep -v grep ; do sleep 1 ; done while ps aux | grep "evoterm --force-shutdown" | grep -v grep ; do sleep 1 ; done evolution exit;; esac echo "Launch: evolution $@" printf "Cancel? [c] " read pushed_key case $pushed_key in c) exit;; esac evolution $@ echo printf "Push enter to close terminal emulation? " read pushed_key exit $ cat /usr/local/bin/evoterm #!/bin/sh roxterm --maximize -T "evolution $*" -e evowrap $* exit But always works here: ]$ cat /usr/local/sbin/alice #!/bin/bash [snip] case $1 in [snip] --off) echo ; poff -a ; ip link set enp3s0 down ; echo -n "Progress: " while pidof pppd > /dev/null ; do echo -n "." ; sleep 3 ; done ; echo ; modprobe -vr pppoe ; echo ; exit ;; [snip] Regards, Ralf -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/1402816212.3692.54.camel@archlinux