Re: rebase [-i --exec | -ix] <CMD>...
Am 07.06.2012 18:46, schrieb Lucien Kong:
Show 15 quoted lines
> +# Add commands after a pick or after a squash/fixup serie
> +# in the todo list.
> +add_exec_commands () {
> + OIFS=$IFS
> + IFS=$LF
> + for i in $cmd
> + do
> + tmp=$(sed "/^pick .*/i\exec $i" "$1")
> + echo "$tmp" >"$1"
> + tmp=$(sed '1d' "$1")
> + echo "$tmp" >"$1"
> + echo "exec $i" >>"$1"
> + done
> + IFS=$OIFS
> +}How about this?
{
first=t
while read -r insn rest
do
case $insn in
pick)
test -n "$first" ||
printf "%s" "$cmd"
;;
esac
printf "%s %s\n" "$insn" "$rest"
first=
done
printf "%s" "$cmd"
} <"$1" >"$1.new" &&
mv "$1.new" "$1"together with:
Show 5 quoted lines
> + -x)
> + test 2 -le "$#" || usage
> + cmd="${cmd:+"$cmd$LF"} $2"
> + shift
> + ;; cmd="${cmd}exec $2${LF}"(I did not test this.)
-- Hannes