[EMAIL PROTECTED] schrieb:
Hi,
I am working on a script and ran into an unusual program. Consider the
following script which I called how.sh.
=====
#!/bin/bash
error () {
echo -e "\n\terror: ${*}\n"
exit;
# kill $$
}
check_file () {
input="$*"
if [ -e $input ]; then
echo "$input"
else
error "invalid directory: $input"
fi
}
chkFile="`check_file $1`"
echo $chkFile
echo "don't print"
=====
When I run the command above I get this output:
# ./how.sh /asdf
error: invalid directory: /asdf
don't print
The reason is that `check_file` is executed in a subshell, so 'exit'
just leaves the subshell, not the script itself.
The command substitution is unnecessary anyway, as the result (if any)
will simply be $1 itself. Thus, if you replace the main part by
check_file $1
echo $1
it should work as expected.
Regards,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de