[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unhelpful behaviors in 4.2.10(1)
From: |
Linda Walsh |
Subject: |
Unhelpful behaviors in 4.2.10(1) |
Date: |
Fri, 08 Jun 2012 18:01:03 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
File1:
sdf:
Ishtar:/tmp> more sdf
#!/bin/bash
_prgpth="${0:?}"; _prg="${_prgpth##*}"; _prgdr="${_prgpth%/$_prg}"
[[ -z $_prgdr || $_prg == $_prgdr ]] && $_prgdr="$PWD"
export PATH="$_prgdr/lib:$_prgdr:$PATH"
shopt -s expand_aliases extglob sourcepath ; set -o pipefail
. backtrace.shh
. sdf2
--------------------------------
file2: sdf2
#!/bin/bash
[[ $# -ge 2 ]] && echo weird
--------------------------------
running:
Ishtar:/tmp> sdf
Error executing "[[ $# -ge 2 ]]" in "main"
at "./sdf", line "4" (level=0)
---
So why am I getting a backtrace (and how do I make it put out the right
file)?
I thought rather than something just dying -- it would be nice to know
how it got there... so...backtrace... but the line it is complaining about
is in "sdf2" --- and WTF?... how is testing a number an error that would
cause a
exception?
(if this was running under -e, I presume that if statements that are
false now fail?... )...I thought complex statements were not supposed to
fail
POSIX really F-U'ed on this one... go back to bash 2's "simple
statements"...
having conditional statements fail is going overboard...
I mean it's an explicit check to avoid an error condition...so, of course,
such checks are now errors?!?!?!....ARG *hitting head against wall....***
file:
backtrace.shh:
more /home/law/bin/lib/backtrace.shh
#!/bin/bash
function backtrace {
declare -i level=0
while {
local cmd=$BASH_COMMAND
local fn=${FUNCNAME[level+1]:-}
local src=${BASH_SOURCE[level+1]:-}
local ln=${BASH_LINENO[level]:-}
}; do
[[ -n $fn && -n $src && -n $ln ]] && {
echo " Error executing \"$cmd\" in \"$fn\""
echo " at \"$src\", line \"$ln\" (level=$level)"
level+=1
continue;
}
exit 1
done
}
trap backtrace ERR
set -T
- Unhelpful behaviors in 4.2.10(1),
Linda Walsh <=
- Re: Unhelpful behaviors in 4.2.10(1), Pierre Gaston, 2012/06/09
- Re: Unhelpful behaviors in 4.2.10(1), Linda Walsh, 2012/06/09
- Re: Unhelpful behaviors in 4.2.10(1), Pierre Gaston, 2012/06/09
- Re: Unhelpful behaviors in 4.2.10(1), Chet Ramey, 2012/06/09
- Re: Unhelpful behaviors in 4.2.10(1), Linda Walsh, 2012/06/09
- Re: bash giving wrong message for indicated failure (was Re: Unhelpful behaviors in 4.2.10(1)), Linda Walsh, 2012/06/13
- Re: bash giving wrong message for indicated failure (was Re: Unhelpful behaviors in 4.2.10(1)), Chet Ramey, 2012/06/14
- Re: bash giving wrong message for indicated failure (was Re: Unhelpful behaviors in 4.2.10(1)), Linda Walsh, 2012/06/14