blob: 87733dac8a4ba47a617e886a9b1e1bf336a71874 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
#---------------------------------------------
# xdg-realpath
#
# Utility script to canonicalize filepaths.
#
# Copyright 2023, Slatian <baschdel@disroot.org>
#
# LICENSE:
#
#---------------------------------------------
manualpage()
{
cat << _MANUALPAGE
_MANUALPAGE
}
usage()
{
cat << _USAGE
_USAGE
}
XDG_UTILS_ENABLE_DOUBLE_HYPEN="y"
#@xdg-utils-common@
set -e
[ -n "$1" ] || exit_failure_syntax
past_double_hyphen=""
exit_with_missing_status=""
while [ $# -gt 0 ] ; do
if [ -n "$past_double_hyphen" ] ; then
[ -e "$1" ] || echo "@NAME@: $1: No such file or directory" >&2
xdg_realpath "$1"
else
case "$1" in
--)
past_double_hyphen="y"
;;
--get-backend)
xdg_realpath || true
echo "$XDG_UTILS_REALPATH_BACKEND"
;;
-*)
exit_failure_syntax "Unknown option: '$1'"
;;
*)
xdg_realpath "$1"
;;
esac
fi
shift
done
[ -z "$exit_with_missing_status" ] || exit_failure_file_missing
|