forked from oldratlee/useful-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathap
More file actions
executable file
·28 lines (25 loc) · 637 Bytes
/
ap
File metadata and controls
executable file
·28 lines (25 loc) · 637 Bytes
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
#!/bin/bash
# @Function
# convert to Absolute Path.
#
# @Usage
# # print Absolute Path of current directory.
# $ ./ap
# # print Absolute Path of arguments.
# $ ./ap a.txt ../dir1/b.txt
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-ap-and-rp
# @author Jerry Lee (oldratlee at gmail dot com)
set -eEuo pipefail
READLINK_CMD=readlink
if command -v greadlink > /dev/null; then
READLINK_CMD=greadlink
fi
[ $# -eq 0 ] && files=(.) || files=("$@")
for f in "${files[@]}"; do
! [ -e "$f" ] && {
echo "$f does not exists!"
continue
}
$READLINK_CMD -f "$f"
done