diff options
author | EuAndreh <eu@euandre.org> | 2021-06-12 19:01:31 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-06-12 19:01:31 -0300 |
commit | 69c4a5e27cfb4a347987e2dc5c9c20b29cce7d0a (patch) | |
tree | 6a5030f6f6030457c5fa70e237097642c8449424 /src/git-permalink.sh | |
parent | tests/xdg-open: Remove unused file (diff) | |
download | git-permalink-69c4a5e27cfb4a347987e2dc5c9c20b29cce7d0a.tar.gz git-permalink-69c4a5e27cfb4a347987e2dc5c9c20b29cce7d0a.tar.xz |
src/git-permalink.sh: Fix bad treatment of -p flag
Diffstat (limited to 'src/git-permalink.sh')
-rwxr-xr-x | src/git-permalink.sh | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/git-permalink.sh b/src/git-permalink.sh index f664b9e..d861ccd 100755 --- a/src/git-permalink.sh +++ b/src/git-permalink.sh @@ -1,14 +1,6 @@ #!/bin/sh set -eu -FILE="${1:-}" -MYLINENO="${2:-}" -COMMIT="$(git rev-parse HEAD)" -ORIGIN="$(git config remote.origin.url)" -OVERRIDE_CF="$(git config git-permalink.template-commit-file ||:)" -OVERRIDE_FC="$(git config git-permalink.template-file-commit ||:)" -REPOSITORY="$(basename "$PWD")" - usage() { printf 'Usage: %s [-p] FILE [LINENO]\n' "$0" } @@ -27,13 +19,18 @@ version() { echo 'git-permalink-@VERSION@ @DATE@' } -if [ -z "$FILE" ]; then +PRINTONLY=false +if [ "${1:-}" = '-p' ]; then + PRINTONLY=true + shift +fi +if [ -z "${1:-}" ]; then printf "Missing \$FILE argument\n\n" >&2 usage >&2 exit 2 fi +FILE="$1" -PRINTONLY=false # shellcheck disable=2068 for flag in $@; do case "$flag" in @@ -46,15 +43,19 @@ for flag in $@; do version exit ;; - -p) - PRINTONLY=true - shift - ;; *) ;; esac done +FILE="${1:-}" +MYLINENO="${2:-}" +COMMIT="$(git rev-parse HEAD)" +ORIGIN="$(git config remote.origin.url)" +OVERRIDE_CF="$(git config git-permalink.template-commit-file ||:)" +OVERRIDE_FC="$(git config git-permalink.template-file-commit ||:)" +REPOSITORY="$(basename "$PWD")" + euandreh() { printf 'https://git.euandreh.xyz/%s/tree/%s?id=%s%s\n' "$REPOSITORY" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" } |