Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
libre
keyringer-macosx
Commits
81d46bd2
Commit
81d46bd2
authored
Apr 24, 2016
by
Michał 'rysiek' Woźniak
Browse files
readlink-f function added for Mac OS X support
parent
29d1d44e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
9 deletions
+51
-9
keyringer
keyringer
+51
-9
No files found.
keyringer
View file @
81d46bd2
...
...
@@ -138,6 +138,48 @@ function keyringer_dispatch {
fi
}
# Mac OS X's readlink version does not support '-f'
# fixing that
if
readlink
-f
"
$0
"
;
then
# great, a regular readlink -f will do!
function
readlink-f
{
readlink
-f
"
$@
"
return
$?
}
elif
greadlink
-f
"
$0
"
;
then
# ah, we have greadlink available, let's use that then.
function
readlink-f
{
readlink
-f
"
$@
"
return
$?
}
else
# apparently we have to do this manually
# based on http://stackoverflow.com/a/1116890
function
readlink-f
{
# save the working directory
WORKDIR
=
"
$(
pwd
)
"
# iterate through all the files in question
for
TARGET_FILE
in
"
$@
"
;
do
cd
"
$(
dirname
$TARGET_FILE
)
"
TARGET_FILE
=
`
basename
$TARGET_FILE
`
# Iterate down a (possible) chain of symlinks
while
[
-L
"
$TARGET_FILE
"
]
do
TARGET_FILE
=
"
$(
readlink
$TARGET_FILE
)
"
cd
"
$(
dirname
$TARGET_FILE
)
"
TARGET_FILE
=
"
$(
basename
$TARGET_FILE
)
"
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
echo
"
$(
pwd
-P
)
/
$TARGET_FILE
"
done
# get back to the original workdir
cd
"
$WORKDIR
"
}
fi
# Config
NAME
=
"keyringer"
KEYRINGER_VERSION
=
"0.3.8"
...
...
@@ -152,30 +194,30 @@ ACTION="$2"
set
-f
# Set functions location
if
[
-e
"
`
dirname
$(
readlink
-f
$0
)
`
/lib/
$NAME
/functions"
]
;
then
if
[
-e
"
`
dirname
$(
readlink-f
$0
)
`
/lib/
$NAME
/functions"
]
;
then
# Development or local installation layout
LIB
=
"
`
dirname
$(
readlink
-f
$0
)
`
/lib/
$NAME
/functions"
LIB
=
"
`
dirname
$(
readlink-f
$0
)
`
/lib/
$NAME
/functions"
else
# System installation layout
LIB
=
"
`
dirname
$(
readlink
-f
$0
)
`
/../lib/
$NAME
/functions"
LIB
=
"
`
dirname
$(
readlink-f
$0
)
`
/../lib/
$NAME
/functions"
fi
# Set shared files location
if
[
-e
"
`
dirname
$(
readlink
-f
$0
)
`
/share/
$NAME
"
]
;
then
if
[
-e
"
`
dirname
$(
readlink-f
$0
)
`
/share/
$NAME
"
]
;
then
# Development or local installation layout
SHARE
=
"
`
dirname
$(
readlink
-f
$0
)
`
/share/
$NAME
"
SHARE
=
"
`
dirname
$(
readlink-f
$0
)
`
/share/
$NAME
"
else
# System installation layout
SHARE
=
"
`
dirname
$(
readlink
-f
$0
)
`
/../share/
$NAME
"
SHARE
=
"
`
dirname
$(
readlink-f
$0
)
`
/../share/
$NAME
"
fi
# Set actions location
if
[
-e
"
`
dirname
$(
readlink
-f
$0
)
`
/lib/
$NAME
/actions"
]
;
then
if
[
-e
"
`
dirname
$(
readlink-f
$0
)
`
/lib/
$NAME
/actions"
]
;
then
# Development or local installation layout
ACTIONS
=
"
`
dirname
$(
readlink
-f
$0
)
`
/lib/
$NAME
/actions"
ACTIONS
=
"
`
dirname
$(
readlink-f
$0
)
`
/lib/
$NAME
/actions"
else
# System installation layout
ACTIONS
=
"
`
dirname
$(
readlink
-f
$0
)
`
/../lib/
$NAME
/actions"
ACTIONS
=
"
`
dirname
$(
readlink-f
$0
)
`
/../lib/
$NAME
/actions"
fi
# Export globals for other scripts
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment