Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
ghcup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Haskell
ghcup
Commits
8a6ff2ff
Unverified
Commit
8a6ff2ff
authored
6 years ago
by
Julian Ospald
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/pr/90'
parents
a3cc8386
17aafe34
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghcup
+10
-4
10 additions, 4 deletions
ghcup
with
10 additions
and
4 deletions
ghcup
+
10
−
4
View file @
8a6ff2ff
...
...
@@ -1130,29 +1130,35 @@ get_distro_alias() {
# and
# https://stackoverflow.com/a/246128
#
# If the file does not exist, just prints
the argument unchanged
.
# If the file does not exist, just prints
it appended to the current directory
.
# @STDOUT: realpath of the given file
posix_realpath
()
{
[
-z
"
$1
"
]
&&
die
"Internal error: no argument given to posix_realpath"
current_loop
=
0
max_loops
=
50
mysource
=
$1
while
[
-h
"
${
mysource
}
"
]
;
do
current_loop
=
$((
current_loop+1
))
mydir
=
"
$(
cd
-P
"
$(
dirname
"
${
mysource
}
"
)
"
>
/dev/null 2>&1
&&
pwd
)
"
mysource
=
"
$(
readlink
"
${
mysource
}
"
)
"
[
"
${
mysource
%
${
mysource
#?
}}
"
x
!=
'/x'
]
&&
mysource
=
"
${
mydir
}
/
${
mysource
}
"
if
[
${
current_loop
}
-gt
${
max_loops
}
]
;
then
(>
&2
echo
"
${
1
}
: Too many levels of symbolic links"
)
break
fi
done
mydir
=
"
$(
cd
-P
"
$(
dirname
"
${
mysource
}
"
)
"
>
/dev/null 2>&1
&&
pwd
)
"
# TODO: better distinguish between "does not exist" and "permission denied"
if
[
-z
"
${
mydir
}
"
]
;
then
(>
&2
echo
"
${
1
}
: Permission denied"
)
elif
[
!
-e
"
$1
"
]
;
then
echo
"
${
mysource
}
"
else
echo
"
${
mydir
%/
}
/
$(
basename
"
${
mysource
}
"
)
"
fi
unset
mysource mydir posix_realpath_erro
r
unset
current_loop max_loops mysource mydi
r
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment