Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tagpreview only modify filepath if tagfile present #1280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions bin/tagpreview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ REVERSE="\x1b[7m"
RESET="\x1b[m"

if [ -z "$1" ]; then
echo "usage: $0 FILENAME:TAGFILE:EXCMD"
echo "usage: $0 FILENAME[:TAGFILE]:EXCMD"
exit 1
fi

IFS=':' read -r FILE TAGFILE EXCMD <<< "$*"
IFS=':' read -r FILE ARG1 ARG2 <<< "$*"

# Complete file paths which are relative to the given tag file
if [ "${FILE:0:1}" != "/" ]; then
FILE="$(dirname "${TAGFILE}")/${FILE}"
if [ -n "$ARG2" ]; then
TAGFILE="$ARG1"
EXCMD="$ARG2"
# Complete file paths which are relative to the given tag file
if [ "${FILE:0:1}" != "/" ]; then
FILE="$(dirname "${TAGFILE}")/${FILE}"
fi
else
EXCMD="$ARG1"
fi

if [ ! -r "$FILE" ]; then
Expand Down