Skip to content

Commit 2273d84

Browse files
committed
Move readlink() so it can work
1 parent 0854d45 commit 2273d84

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

share/github-backup-utils/ghe-backup-config

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ YELLOW='\033[0;33m'
2121
BLUE='\033[0;34m'
2222
NC='\033[0m' # No Colo# Logging display and formatting functions
2323

24+
# If we don't have a readlink command, parse ls -l output.
25+
if ! type readlink 1>/dev/null 2>&1; then
26+
readlink() {
27+
local ret=0 f=''
28+
while [ $# -gt 0 ]; do
29+
f="$1"
30+
shift 1
31+
32+
[ ! -e "$f" ] && [ ! -h "$f" ] && {
33+
ret=1
34+
continue
35+
}
36+
37+
# shellcheck disable=SC2012 # In this specific scenario, this method is OK
38+
f="$(ls -ld "$f")"
39+
echo "${f//*-> /}"
40+
done
41+
42+
return $ret
43+
}
44+
fi
45+
2446
# Log a message to stdout
2547
log_level() {
2648
local level=$1
@@ -402,28 +424,6 @@ ghe_remote_version_config() {
402424
###############################################################################
403425
### Utility functions
404426

405-
# If we don't have a readlink command, parse ls -l output.
406-
if ! type readlink 1>/dev/null 2>&1; then
407-
readlink() {
408-
local ret=0 f=''
409-
while [ $# -gt 0 ]; do
410-
f="$1"
411-
shift 1
412-
413-
[ ! -e "$f" ] && [ ! -h "$f" ] && {
414-
ret=1
415-
continue
416-
}
417-
418-
# shellcheck disable=SC2012 # In this specific scenario, this method is OK
419-
f="$(ls -ld "$f")"
420-
echo "${f//*-> /}"
421-
done
422-
423-
return $ret
424-
}
425-
fi
426-
427427
# Run ghe-host-check and establish the version of the remote GitHub instance in
428428
# the exported GHE_REMOTE_VERSION variable. If the remote version has already
429429
# been established then don't perform the host check again. Utilities in share/github-backup-utils

0 commit comments

Comments
 (0)