====== Issue 2014 - November ====== ===== Writing shell in a portable way is ... ===== Well, I guess word ''issue'' is spot on just now. Writing shell scripts in portable way seems to be anything but easy and intuitive :-) Yes, I'm having a bit of an issue here. Small code snippet #!/bin/sh on_error() { printf -- "Can I access date '%s' here as well?\n" "${DATE}" } DATE=$(date) printf -- "Today is %s\n" "${DATE}" trap on_error 1 2 15 sleep 3600 Where is the problem at? It's in ''trap'' and the fact you can't use ''SIGHUP'', ''SIGINT'', ''SIGTERM'' and alike, but you have to use signal numbers. And to use ''#!/bin/bash'' as a solution? Please! **UPDATE**: Actually, you can use ''HUP'', ''INT'' and ''TERM'' according to [[https://wiki.icflix.com/|this wiki page]]. Also, reading POSIX web page about [[http://pubs.opengroup.org/onlinepubs/009695399/utilities/trap.html|trap]] is helpful ;-) And don't get me wrong. I'm more or less making fun out of it. I didn't know or forgotten all about it. May be somebody will find this useful.