2021-10-22 19:24:02 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
new_tmp_dir() {
|
|
|
|
local dirname
|
|
|
|
dirname=$(mktemp -d)
|
|
|
|
mkdir -p "$dirname"
|
|
|
|
cd "$dirname"
|
|
|
|
trap "rm -rf '$dirname'" EXIT
|
|
|
|
}
|
|
|
|
|
2022-10-21 08:13:09 +03:00
|
|
|
run_command() {
|
|
|
|
echo "\$ $@"
|
|
|
|
eval "$@"
|
2021-10-23 19:34:58 +03:00
|
|
|
}
|
2021-10-23 19:22:45 +03:00
|
|
|
|
2023-08-29 08:59:58 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-21 08:13:09 +03:00
|
|
|
blank() {
|
|
|
|
echo ""
|
|
|
|
}
|
2021-10-22 19:24:02 +03:00
|
|
|
|
2022-10-21 08:13:09 +03:00
|
|
|
comment() {
|
|
|
|
indented="$(echo "$@"| sed 's/^/# /g')"
|
|
|
|
blank
|
|
|
|
echo -e "\033[0;32m${indented}\033[0m"
|
|
|
|
blank
|
2021-10-22 19:24:02 +03:00
|
|
|
}
|