File: sensible-pager

package info (click to toggle)
sensible-utils 0.0.26
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 604 kB
  • sloc: sh: 859; makefile: 122; sed: 88
file content (29 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# Copyright 2007 Jari Aalto; Released under GNU GPL v2 or any later version

# Prevent recursive loops, where environment variables are set to this script
[ -n "$__SENSIBLE_PAGER" ] && exit 126
__SENSIBLE_PAGER="$0"
export __SENSIBLE_PAGER

Try()
{
    [ -z "$__sensible_candidate" ] && return
    eval "$__sensible_candidate \"\$@\""; ret=$?
    # 127=ENOENT, 126=couldn't exec for another reason
    [ "$ret" -ne 126 ] && [ "$ret" -ne 127 ] && exit "$ret"
    unset ret
}

# shellcheck disable=SC2153
for __sensible_candidate in "$PAGER" "$SENSIBLE_PAGER" pager more; do
    Try "$@"
done


command -v gettext > /dev/null || alias gettext='printf %s'
# shellcheck disable=SC2016
TEXTDOMAIN=sensible-utils gettext 'Couldn'\''t find a pager!
Set the $PAGER environment variable to your desired pager.
' >&2
exit 1