Paul Jarc wrote:
Linda Walsh <[EMAIL PROTECTED]> wrote:
# *1 - using "-e" stops your script immediately on any error
Not any error - only those from simple commands. The subtleties are
subtle enough that I avoid -e, and use "&&" between all commands
instead.
paul
Yeah...it doesn't catc
Dang---you're right of course. Didn't test the error case...too used to perl.
That's why I drag myself through shell scripts trying to do things I
might be tempted to do in perl...*sigh*
probably have to resort to a else block, running "Error", then
returning the status, i.e.:
---
else
Linda Walsh <[EMAIL PROTECTED]> writes:
> Check_file ()
> {
> if [[ -d "$1" ]]; then echo "$1" # *4
> else return Error "invalid directory: \"$1\""; fi
"return" expects a number, not the string "Error" as the first argument
and does not take any further argum
Linda Walsh <[EMAIL PROTECTED]> wrote:
> # *1 - using "-e" stops your script immediately on any error
Not any error - only those from simple commands. The subtleties are
subtle enough that I avoid -e, and use "&&" between all commands
instead.
paul
In the spirit of there being more than one solution to every problem,
I made the solution "more complicated" :-) in case you wanted
to check more error conditions...
I included some "Notes" about why I did some things they way I
did, since it may not be immediately obvious. Some of them are
proba
> [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 ()
> [EMAIL PROTECTED] writes:
>
>> =
>>
>> #!/bin/bash
>>
>> error () {
>>
>>echo -e "\n\terror: ${*}\n"
>>exit;
>
> Replace that with "exit 1". You can use any other non-zero exit code.
>
>># kill $$
>>
>> }
>>
>> check_file () {
>>
>>input="$*"
>>
>>if [ -e $input ]; then
>
[EMAIL PROTECTED] writes:
> =
>
> #!/bin/bash
>
> error () {
>
>echo -e "\n\terror: ${*}\n"
>exit;
Replace that with "exit 1". You can use any other non-zero exit code.
># kill $$
>
> }
>
> check_file () {
>
>input="$*"
>
>if [ -e $input ]; then
This will fail if the ar
[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