Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] vcs_info: avoid errors on missing file



As per remark on 33391, use $(cat) rather than $(<) construct to
continue execution.
This will at least fix the pb on opening a shell on a path on which
a git rebase -i is running but has not started to rebase because
no rebase-merge/done exist.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr |  2 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs |  2 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 24 +++++++++++------------
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  |  6 +++---
 Functions/VCS_Info/VCS_INFO_quilt                 |  2 +-
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
index cae1a3b..ed540e7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
@@ -50,7 +50,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then
     bzrbase=${vcs_comm[basedir]}
     bzrinfo[2]=${bzrbase:t}
     if [[ -f ${bzrbase}/.bzr/branch/last-revision ]] ; then
-        bzrinfo[1]=$(< ${bzrbase}/.bzr/branch/last-revision)
+        bzrinfo[1]=$(cat ${bzrbase}/.bzr/branch/last-revision)
         bzrinfo[1]=${${bzrinfo[1]}%% *}
     fi
 else
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
index ed738b9..7e8b8aa 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
@@ -10,7 +10,7 @@ while [[ -d "${cvsbase}/../CVS" ]]; do
     cvsbase="${cvsbase}/.."
 done
 cvsbase="$(VCS_INFO_realpath ${cvsbase})"
-cvsbranch=$(< ./CVS/Repository)
+cvsbranch=$(cat ./CVS/Repository)
 rrn=${cvsbase:t}
 cvsbranch=${cvsbranch##${rrn}/}
 [[ -z ${cvsbranch} ]] && cvsbranch=${rrn}
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 48d552f..781cbdd 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -86,17 +86,17 @@ VCS_INFO_git_getbranch () {
     if [[ -n ${actiondir} ]]; then
         gitbranch="$(${(z)gitsymref} 2> /dev/null)"
         [[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \
-            && gitbranch="$(< ${actiondir}/head-name)"
+            && gitbranch="$(cat ${actiondir}/head-name)"
 
     elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
         gitbranch="$(${(z)gitsymref} 2> /dev/null)"
-        [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/MERGE_HEAD)"
+        [[ -z ${gitbranch} ]] && gitbranch="$(cat ${gitdir}/MERGE_HEAD)"
 
     elif [[ -d "${gitdir}/rebase-merge" ]] ; then
-        gitbranch="$(< ${gitdir}/rebase-merge/head-name)"
+        gitbranch="$(cat ${gitdir}/rebase-merge/head-name)"
 
     elif [[ -d "${gitdir}/.dotest-merge" ]] ; then
-        gitbranch="$(< ${gitdir}/.dotest-merge/head-name)"
+        gitbranch="$(cat ${gitdir}/.dotest-merge/head-name)"
 
     else
         gitbranch="$(${(z)gitsymref} 2> /dev/null)"
@@ -105,7 +105,7 @@ VCS_INFO_git_getbranch () {
             gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)"
 
             if [[ $? -ne 0 ]] ; then
-                gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
+                gitbranch="${${"$(cat $gitdir/HEAD)"}[1,7]}..."
             fi
         fi
     fi
@@ -199,13 +199,13 @@ local patchdir=${gitdir}/patches/${gitbranch}
 if [[ -d $patchdir ]] && [[ -f $patchdir/applied ]] \
    && [[ -f $patchdir/unapplied ]]
 then
-    git_patches_applied=(${(f)"$(< "${patchdir}/applied")"})
-    git_patches_unapplied=(${(f)"$(< "${patchdir}/unapplied")"})
+    git_patches_applied=(${(f)"$(cat "${patchdir}/applied")"})
+    git_patches_unapplied=(${(f)"$(cat "${patchdir}/unapplied")"})
     VCS_INFO_git_handle_patches
 elif [[ -d "${gitdir}/rebase-merge" ]]; then
     patchdir="${gitdir}/rebase-merge"
     local p
-    for p in ${(f)"$(< "${patchdir}/done")"}; do
+    for p in ${(f)"$(cat "${patchdir}/done")"}; do
         # remove action
         git_patches_applied+=("${${(s: :)p}[2,-1]}")
     done
@@ -214,18 +214,18 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
 elif [[ -d "${gitdir}/rebase-apply" ]]; then
     # Fake patch names for all but current patch
     patchdir="${gitdir}/rebase-apply"
-    local cur=$(< "${patchdir}/next")
+    local cur=$(cat "${patchdir}/next")
     local p subject
     for p in $(seq $(($cur - 1))); do
         git_patches_applied+=("$(printf "%04d" $p) ?")
     done
-    subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+    subject="${$(cat "${patchdir}/msg-clean")[(f)1]}"
     if [[ -f "${patchdir}/original-commit" ]]; then
-        git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
+        git_patches_applied+=("$(cat ${patchdir}/original-commit) $subject")
     else
         git_patches_applied+=("? $subject")
     fi
-    git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
+    git_patches_unapplied=($(seq $cur $(cat "${patchdir}/last")))
 
     VCS_INFO_git_handle_patches
 else
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index cedaf56..a8a74fc 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -60,7 +60,7 @@ fi
 
 # If the user doesn't opt to invoke hg we can still get the current branch
 if [[ -z ${r_branch} && -r ${branchfile} ]] ; then
-    r_branch=$(< ${branchfile})
+    r_branch=$(cat ${branchfile})
 fi
 
 # If we still don't know the branch it's safe to assume default
@@ -138,7 +138,7 @@ fi
 if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
         && [[ -d $patchdir ]] ; then
     if [[ -e $mqstatusfile ]]; then
-        mqpatches=( ${${(f)"$(< "${patchdir}/status")"}/(#s)[a-f0-9]##:/} )
+        mqpatches=( ${${(f)"$(cat "${patchdir}/status")"}/(#s)[a-f0-9]##:/} )
         mqpatches=( ${(Oa)mqpatches} )
     fi
 
@@ -149,7 +149,7 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
 
         # Collect active guards
         if [[ -r ${mqguardsfile} ]]; then
-            mqguards=( ${(f)"$(< "${mqguardsfile}")"} )
+            mqguards=( ${(f)"$(cat "${mqguardsfile}")"} )
             mqguards=( ${(oa)mqguards} )
         fi
 
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index db15dda..258a08a 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -122,7 +122,7 @@ function VCS_INFO_quilt() {
         [[ ${quiltmode} == 'standalone' ]] && root=${pc}
         pc=${pc}/.pc
         if [[ -e ${pc}/applied-patches ]]; then
-            applied=( ${(f)"$(<$pc/applied-patches)"} )
+            applied=( ${(f)"$(cat $pc/applied-patches)"} )
             # throw away empty entries
             applied=( ${applied:#} )
             applied=( ${(Oa)applied} )
-- 
2.1.1



Messages sorted by: Reverse Date, Date, Thread, Author