RE: Bash scripting problem
Hello,
If you read the man about bash, you will find out that all commands after a
pipeline are executed in a subshell.
It's not a bash bug !
Perhaps, if you try this :
#!/bin/bash -e
found_driver=0
echo -n "Starting sound driver: "
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 < awk '/^alias +snd-card-[0-9]/ {print $3}' /etc/modules.conf
echo "DEBUG3: found_driver=$found_driver"
Hope it's help!
Christophe Abrial
LSA France
Systems and Networks Solutions
-----Message d'origine-----
De : Martin Fluch [mailto:fluch@rock.helsinki.fi]
Envoye : mardi 2 mai 2000 09:43
A : debian-user@lists.debian.org
Objet : 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
--
Unsubscribe? mail -s unsubscribe debian-user-request@lists.debian.org <
/dev/null
Reply to: