New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor improvements to perlbrew-install #568
Conversation
If the perl executable is not found into one of the well known places during the loop the error message is shown, otherwise the first executable found is used as system-wide Perl.
This is coherent with the same usage of -z a few lines under this code.
It does not make sense to change dir to '.'.
Make the clean_exit function callable from the very beginning of the script and use it instead of "plain" exit.
3 similar comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it looks OK to altering exit() status, I'm curious: do you plan to depen on those values for some application ?
PERLBREWURL=https://raw.githubusercontent.com/gugod/App-perlbrew/master/perlbrew | ||
fi | ||
|
||
if [ -z "$TMPDIR" ]; then | ||
if [ -d "/tmp" ]; then | ||
TMPDIR="/tmp" | ||
cd $TMPDIR || clean_exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only cd $TMPDIR
if $TMPDIR
is not the current directory, but what happens if $TMPDIR
is set in the environment? Then no cd
happens. Is that correct?
exit $1 | ||
} | ||
|
||
LOCALINSTALLER=$(mktemp perlbrew.XXXXXX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a file in the current directory (at least in GNU mktemp); see https://www.gnu.org/software/coreutils/manual/html_node/mktemp-invocation.html#mktemp-invocation .
I commented on two lines that are causing me weird behavior: empty
My guess is that the original author of this PR had |
As per discussion in <gugod#568 (review)> the TMPDIR variable could have been set from the environment and in such case no 'cd' happens leaving the installer in the current directory. Thanks @jonathancast
Since mktemp is not called with '-p' the temporary file is created relatively to the current directory. Since the directory is changed after the temporary file is created, this could leave the installer with a dangling file. See discussion <gugod#568 (review)> Thanks to @jonathancast.
Now the installation script has a few more extra checks for existance of the directories and installation file since the script could die in the early stage and leave some dangling file. see discussion <gugod#568 (review)>
A set of minor shell improvements to perlbrew-install in order to make the shell script more coherent.
Tested on bash 4.4.7 and zsh 5.2 on ubuntu linux.