Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Interrupting globs (Re: Something rotten in tar completion)



On Dec 7,  8:20pm, Peter Stephenson wrote:
}
} +vinde(TRY_BLOCK_INTERRUPT)
} +item(tt(TRY_BLOCK_INTERRUPT) <S>)(
} +This variable works in a similar way to tt(TRY_BLOCK_ERROR), but
} +represents the status of an interrupt from the keyboard typically
} +by the user typing tt(^C).  If set to 0, any such interrupt will
} +be reset; otherwise, the interrupt is propagated after the tt(always)
} +block.

I worry a little about describing it like this.  It's an INT signal,
but whether it came "from the keyboard" is not really known.  If you
move the word "typically" to before the word "from", the description
becomes more accurate.

It might also be worth mentioning that if an interrupt happens DURING
the always-block, then the always block will stop and THAT interrupt
is also propagated.

This all could lead to code like this:

    {
      : Dammit, stop interrupting me
    } always {
      () {
	integer queued_signal=0
	() {
	  setopt localoptions localtraps
	  TRAPINT() {
	    (( ++queued_signal ))
	    return 0
	  }
	  while interrupts are impossible
	  do something important
	  done
	}
	if (( queued_signal ))
	then TRY_BLOCK_INTERRUPT=1	# Does this work?
	fi
      }
    }



Messages sorted by: Reverse Date, Date, Thread, Author