It turns out the problem was due to the fact that my cleanup function was calling stty, and stty evidently doesn't like to be called while stdin is being redirected from a file. Thus, when I pressed Ctrl-C while the script was executing the read loop, the cleanup function got called as if I had called it from within the loop:

while read -r line; do
  ...
  cleanup
  ...
done &lt; "$filename"


This, in turn, meant that stty was executed with a redirected stdin, and it died with the error stty: standard input: Inappropriate ioctl for device.

I was able to fix this by changing my trap line:

trap "break" SIGINT SIGHUP SIGTERM


So instead of having it effectively insert a call to cleanup into my loop when I press Ctrl-C, it instead just (effectively) inserts a break into the loop, thus breaking out of the loop and subsequently calling the cleanup function via the line after the loop.

Bash script doesn't catch SIGINT while in read loop
I'm having problems getting the field values out of a Bento database using Applescript:

I'mn using the following code to get at the entries but I'm not able to get at the cells or fields associated with the entries. Can anyone point me in the right direction:

tell application "Bento"
repeat with i from 1 to count of libraries
    set theName to name of library i
    log theName
    if theName is equal to "Reconnaissance site report" then
        log "The library has been found"
        set theLibraryProperties to properties of library i
        log theLibraryProperties
        tell library i
            repeat with j from 1 to count of entries
                set theEntryName to id of entry j
                set theEntryProperties to properties of entry j
                log theEntryName
                log theEntryProperties
            end repeat
        end tell
    end if
end repeat
end tell

