upd: fix bug where realpath could crash
This commit is contained in:
parent
01bf4de331
commit
e535616faf
1 changed files with 8 additions and 13 deletions
|
@ -51,21 +51,16 @@ contains() {
|
||||||
pretty_path() {
|
pretty_path() {
|
||||||
arg="$1"
|
arg="$1"
|
||||||
|
|
||||||
|
# If the arg starts with our home dir, replace the prefix with a tilde
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
# If the arg starts with our home dir,
|
|
||||||
"$HOME"*)
|
"$HOME"*)
|
||||||
# replace the home dir part with a ~
|
arg="~${arg#"$HOME"}"
|
||||||
printf '~%s' "$(printf '%s' "$arg" | sed -E 's/^.{'"${#HOME}"'}//')"
|
|
||||||
;;
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Otherwise,
|
printf '%s' "$arg" |
|
||||||
*)
|
tr -s '/' | # Remove duplicate slashes
|
||||||
# Just print the arg
|
sed 's+/$++' # Remove trailing slash
|
||||||
printf '%s' "${arg}"
|
|
||||||
;;
|
|
||||||
esac | # Pass through some other filters
|
|
||||||
sed -E 's_/+$__' | # Remove trailing slash
|
|
||||||
tr -s '/' # Remove duplicate slashes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Warn about incomplete changes to a repository
|
# Warn about incomplete changes to a repository
|
||||||
|
@ -101,7 +96,7 @@ do_pull() {
|
||||||
for repo in "$@"; do
|
for repo in "$@"; do
|
||||||
if [ -n "$repo" ]; then
|
if [ -n "$repo" ]; then
|
||||||
repo_pretty="$(pretty_path "$repo")"
|
repo_pretty="$(pretty_path "$repo")"
|
||||||
repo="$(realpath "$repo" 2>/dev/null)"
|
repo="$(realpath "$repo" 2>/dev/null || true)"
|
||||||
repo="$(git -C "$repo" rev-parse --show-toplevel 2> /dev/null || true)"
|
repo="$(git -C "$repo" rev-parse --show-toplevel 2> /dev/null || true)"
|
||||||
if [ -n "$repo" ]; then
|
if [ -n "$repo" ]; then
|
||||||
if ! contains "$repo" ':' "$updated"; then
|
if ! contains "$repo" ':' "$updated"; then
|
||||||
|
@ -133,7 +128,7 @@ do_pull() {
|
||||||
${did_updates:-false} && echo
|
${did_updates:-false} && echo
|
||||||
echo " Updating ${green}dotfiles${nc}…"
|
echo " Updating ${green}dotfiles${nc}…"
|
||||||
dotfiles pull
|
dotfiles pull
|
||||||
do_checks "$(dotfiles rev-parse --git-dir)" dotfiles
|
do_checks "$(pretty_path "$(dotfiles rev-parse --git-dir)")" dotfiles
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue