mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
eae9e3408d
`jj | head` exits with non-zero code since `head` breaks the pipe. Also, removed `--color=always` from that command as it will shortly become unnecessary. Previosly, this caused the script to stop since it's run with `set -o pipefail`. Also, the operation id recovery code stopped working. We can use `jj debug operation` for this purpose now.
41 lines
645 B
Bash
41 lines
645 B
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
new_tmp_dir() {
|
|
local dirname
|
|
dirname=$(mktemp -d)
|
|
mkdir -p "$dirname"
|
|
cd "$dirname"
|
|
trap "rm -rf '$dirname'" EXIT
|
|
}
|
|
|
|
run_command() {
|
|
echo "\$ $@"
|
|
eval "$@"
|
|
}
|
|
|
|
run_command_allow_broken_pipe() {
|
|
run_command "$@" || {
|
|
EXITCODE="$?"
|
|
case $EXITCODE in
|
|
3)
|
|
# `jj` exits with error coded 3 on broken pipe,
|
|
# which can happen simply because of running
|
|
# `jj|head`.
|
|
return 0;;
|
|
*)
|
|
return $EXITCODE;;
|
|
esac
|
|
}
|
|
}
|
|
|
|
blank() {
|
|
echo ""
|
|
}
|
|
|
|
comment() {
|
|
indented="$(echo "$@"| sed 's/^/# /g')"
|
|
blank
|
|
echo -e "\033[0;32m${indented}\033[0m"
|
|
blank
|
|
}
|