global: Use "command" to run "hg"

This commit is contained in:
Koichi Murase
2022-02-22 17:57:33 +09:00
parent 897876eae1
commit 1453db64c8
2 changed files with 6 additions and 6 deletions

View File

@@ -354,7 +354,7 @@ function get_hg_root {
} }
function hg_prompt_vars { function hg_prompt_vars {
if [[ -n $(hg status 2> /dev/null) ]]; then if [[ -n $(command hg status 2> /dev/null) ]]; then
SCM_DIRTY=1 SCM_DIRTY=1
SCM_STATE=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} SCM_STATE=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else else
@@ -370,14 +370,14 @@ function hg_prompt_vars {
# Mercurial holds it's current branch in .hg/branch file # Mercurial holds it's current branch in .hg/branch file
SCM_BRANCH=$(cat "$HG_ROOT/branch") SCM_BRANCH=$(cat "$HG_ROOT/branch")
else else
SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}') SCM_BRANCH=$(command hg summary 2> /dev/null | grep branch: | awk '{print $2}')
fi fi
if [ -f "$HG_ROOT/dirstate" ]; then if [ -f "$HG_ROOT/dirstate" ]; then
# Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState # Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState
SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' "$HG_ROOT/dirstate" | cut -c-12) SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' "$HG_ROOT/dirstate" | cut -c-12)
else else
SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}') SCM_CHANGE=$(command hg summary 2> /dev/null | grep parent: | awk '{print $2}')
fi fi
} }

View File

@@ -133,15 +133,15 @@ function git_prompt_info() {
# Parse hg info # Parse hg info
function hg_prompt_info() { function hg_prompt_info() {
if [[ -n $(hg status 2> /dev/null) ]]; then if [[ -n $(command hg status 2> /dev/null) ]]; then
local state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} local state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else else
local state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} local state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi fi
local prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} local prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
local suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} local suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
local branch=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') local branch=$(command hg summary 2> /dev/null | grep branch | awk '{print $2}')
local changeset=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') local changeset=$(command hg summary 2> /dev/null | grep parent | awk '{print $2}')
echo -e "$prefix${REF_COLOR}${branch}${DEFAULT_COLOR}:${changeset#*:}$state$suffix" echo -e "$prefix${REF_COLOR}${branch}${DEFAULT_COLOR}:${changeset#*:}$state$suffix"
} }