0

Is it possisble in bash script to use parameters in a function, which is called after interrupt signal? Here's my code:

    inCaseOfInterrupt ()
    {
        while [ $# -gt 0 ]
        do
                echo "$1"
                shift
        done
        exit 0
    }

And in the other part of my script I have:

trap inCaseOfInterrupt 2

But it doesn't recognize my parameters. How can I use parameters in a function after script gets interrupt signal?

Sa1m0n
  • 710
  • 7
  • 14

1 Answers1

0
trap 'inCaseOfInterrupt 2' 2

Or, with a signal name:

trap 'inCaseOfInterrupt 2' INT
John Kugelman
  • 349,597
  • 67
  • 533
  • 578