Bash scripting problem
Hi all!
On my woody box I ran into the following problem:
After I had problem with the /etc/init.d/alsa script I started to track
down the problem and finaly ended with the following script, which doesn't
work like I expect:
#!/bin/bash -e
found_driver=0
echo -n "Starting sound driver: "
awk '/^alias +snd-card-[0-9]/ {print $3}' /etc/modules.conf | \
while read line; do
if /sbin/modprobe $line >/dev/null 2>&1; then
echo "$line"
found_driver=1
echo "DEBUG1: found_driver=$found_driver"
fi
echo "DEBUG2: found_driver=$found_driver"
done
echo "DEBUG3: found_driver=$found_driver"
When I execute this, I get the following output:
root@seneca:/etc/init.d> ./alsa.debug
Starting sound driver: snd-card-cs4236
DEBUG1: found_driver=1
DEBUG2: found_driver=1
DEBUG3: found_driver=0
What me puzzles is: why is finaly $found_driver reseted to 0? Is this a
bash bug (bash --version gives "GNU bash, version 2.04.0(1)-release
(i386-pc-linux-gnu) ...")?
Martin
Reply to: