"Of course you can get errors if there are regions where the functions are infinite like 1/x*(unit_step(x+2) -
unit_step(x-6))".
Try.
(%i1) 1/x*(unit_step(x+2) - unit_step(x-6));
(%o1) (unit_step(x+2)-unit_step(x-6))/x
(%i2) integrate(%, x);
(%o2) (log(x)-log(-2))*unit_step(x+2)-unit_step(x-6)*(log(x)-log(6))
(%i3) integrate(%o1, x, -2,6);
Is x-2 positive, negative, or zero?n;
Is x+6 positive, negative, or zero?p;
Principal Value
(%o3) log(3)
(%i4) integrate(%o1, x, -2,6);
Is x-2 positive, negative, or zero?p;
Is x+6 positive, negative, or zero?n;
Principal Value
(%o4) log(3)+3*%i*%pi
I don't like subtracting minf from inf.
Rich