Trap not work on debian 8
trap not execute on debian with /bin/sh link to /bin/dash
workarround create link /bin/sh to /bin/bash
Or use #!/bin/bash instead of #!/bin/sh
iirc, I used /bin/sh to deal with systems that didn't have bash installed, although I can't remember off the top of my head which systems those were. Happy to switch it to /bin/bash and see how people go - if there are complaints, there'll have to be a new solution.
fair enough. The alternative is to avoid bashisms (e.g. http://mywiki.wooledge.org/Bashism ) for portable shell scripts.
Nice page, thanks. The problem with this one in particular is that the trap is used to ensure that the routing rules are removed on exit, regardless of success or failure. I could, perhaps, move to two scripts and exit codes, but that would take a bit more re-jigging. I don't see a trap alternative on that page.