Mercurial > repos > other > linux
changeset 164:d6bf7ed9024c
Avoid permission errors in output
This happens when a non-root command runs in a dir where a file
has root-only permissions (e.g. the Puppet repo)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 25 May 2024 15:58:34 +0100 |
parents | cfdd6905e453 |
children | 03886f17beef |
files | bashrc |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/bashrc Wed Nov 15 19:28:45 2023 +0000 +++ b/bashrc Sat May 25 15:58:34 2024 +0100 @@ -69,12 +69,15 @@ HG_ROOT=$(rhg root 2>/dev/null) if [[ "x$HG_ROOT" != "x" ]]; then HG_BRANCH=$(<"${HG_ROOT}"/.hg/branch) - HG_MODIFIED=$([ "$(rhg status -marud | head -c1)" ] && echo " *") + HG_MODIFIED=$([ "$(rhg status -marud 2>&1 | grep -v ": Permission denied (os error 13)" | head -c1)" ] && echo " *") HG_INCOMING_PATH="${HG_ROOT}"/.hg/prompt/cache/incoming HG_OUTGOING_PATH="${HG_ROOT}"/.hg/prompt/cache/outgoing + if [[ ! -d "${HG_ROOT}"/.hg/prompt/cache/ ]]; then + mkdir -p "${HG_ROOT}"/.hg/prompt/cache/ + fi if [[ ! -f "${HG_INCOMING_PATH}" || $(($(date +%s) - $(date -r "${HG_INCOMING_PATH}" +%s 2>/dev/null || echo 0) )) -gt $HG_CACHE_TIMEOUT ]]; then - hg incoming --quiet --config ui.interactive=False > "$HG_INCOMING_PATH" - hg outgoing --quiet --config ui.interactive=False > "$HG_OUTGOING_PATH" + hg incoming --quiet --config ui.interactive=False > "$HG_INCOMING_PATH" 2>/dev/null + hg outgoing --quiet --config ui.interactive=False > "$HG_OUTGOING_PATH" 2>/dev/null fi HG_IN=$([ -f "${HG_INCOMING_PATH}" ] && wc -l < "$HG_INCOMING_PATH" 2>/dev/null || echo 0) HG_OUT=$([ -f "${HG_OUTGOING_PATH}" ] && wc -l < "$HG_OUTGOING_PATH" 2>/dev/null || echo 0)