开发者

bash trap debug failure

开发者 https://www.devze.com 2023-03-05 00:59 出处:网络
This program (debug shell) works only if you run it like this: debug_shell script.sh If you have a script like this:

This program (debug shell) works only if you run it like this:

debug_shell script.sh

If you have a script like this:

#!/bin/debug_shell
echo my program

Then it doesn't work.

Source for the "debug_shell":

#!/bin/bash
shopt -s extdebug
function on_debug {
  echo HERE:  $BASH_ARGV
}
t开发者_开发百科rap on_debug DEBUG
. $1

Any idea why it doesn't work (bash 3.2.25)?


Ensure that debug_shell and script.sh have executable bit. Also it's important how you run your script:

$ ./script.sh
HERE: ./script.sh
my program


On my ubuntu 10.04 bash 4.1.5, your stuff works fine.

Are you sure your script.sh is executable ? And be sure you stored the debug_script in /bin of course ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号