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

Re: s/pattern/pattern/g on the commandline ?



On Feb 29,  2:48pm, Christoph (Stucki) von Stuckrad wrote:
}
} BUT I never fond out, how to put the edited lines into the history
} BUT NOT EXCUTE them (once I'm in the editor by fc...).
} So in this case I always saved to some other place and aborted editing.

fc_noexec() {
  integer skip_count=0
  setopt DEBUG_BEFORE_CMD
  TRAPDEBUG() {
    if (( skip_count > 1 ))
    then
	unfunction TRAPDEBUG
	setopt ERR_EXIT no_DEBUG_BEFORE_CMD
	return 1
    else
	(( skip_count++ ))
        return 0
    fi
  }
  fc "$@"
}

I think there's a small bug with DEBUG_BEFORE_CMD in that the debug
trap is executed *twice* for the single command "fc", which is why
the (( skip_count > 1 )) is in there.  If that behavior changes, the
test will also need to change.

Also I've assumed DEBUG_BEFORE_CMD is normally off, tweak that if
you have it on.

-- 
Barton E. Schaefer



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