Skip to content
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

Rename JTstuff #67

Merged
merged 6 commits into from
Apr 18, 2024
Merged

Rename JTstuff #67

merged 6 commits into from
Apr 18, 2024

Conversation

judovana
Copy link
Collaborator

No description provided.

@zzambers
Copy link
Collaborator

zzambers commented Apr 17, 2024

I am not sure, if we want to run readlink at all, in case it does not support -f. In that case, it fails if argument is not symlink (i.e. if javac is not symlink). Even when javac is a symlink, usefulness is somewhat questionable, e.g.:

readlink /usr/bin/javac
/etc/alternatives/javac

@judovana
Copy link
Collaborator Author

judovana commented Apr 17, 2024

I am not sure, if we want to run readlink at all, in case it does not support -f. In that case, it fails if argument is not symlink (i.e. if javac is not symlink). Even when javac is a symlink, usefulness is somewhat questionable, e.g.:

readlink /usr/bin/javac
/etc/alternatives/javac

Yah, I know that. But still better then fail. What troubles me more, is the second usage

if [ ! `readlink $READLINK_F ${SCRIPT_DIR}` == `pwd`  ] ; then

where

readlink "."
echo $?
1
 readlink ".."
echo $?
1
 echo $PWD/..
/home/jvanek/..

So it is making the condition unusable. But still better then fail I think

Maybe resolve CWD as

CryptoTest/run.sh

Lines 11 to 18 in 5064ea3

SCRIPT_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
readonly SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
?

@zzambers
Copy link
Collaborator

Well, if argument is not symlink, it will fail. :)

@zzambers
Copy link
Collaborator

Actually I was also looking at begining of the script, with some effort you could put it in a function and reuse it...

@judovana
Copy link
Collaborator Author

Actually I was also looking at begining of the script, with some effort you could put it in a function and reuse it...

yy!

@zzambers
Copy link
Collaborator

Btw, is then second usage even necessary? As SCRIPT_DIR should already be canonized by that very code on the beginning.

@judovana
Copy link
Collaborator Author

Btw, is then second usage even necessary? As SCRIPT_DIR should already be canonized by that very code on the beginning.

In theory no. I think I added it as safe belt, to prevent nasty surprises

@judovana
Copy link
Collaborator Author

judovana commented Apr 17, 2024

Actually I was also looking at begining of the script, with some effort you could put it in a function and reuse it...

function readlink-f() {
  local SOURCE="${1}"
  if [ -f "${SOURCE}" ] ; then
    local NAME="/$(basename "${SOURCE}")"
  else
    local SOURCE="$SOURCE/blah"
    local NAME=""
  fi
  while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
    local DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
    local SOURCE="$(readlink "$SOURCE")"
    # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
  done
  local RESULT="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  echo "${RESULT}${NAME}"
}
}

Wookrs fine for all except symlinked file, which is natureal due to dirname usage.. Morning would be better then evening. Thanx and see you tomorrow!

@judovana
Copy link
Collaborator Author

Actually I was also looking at begining of the script, with some effort you could put it in a function and reuse it...

function readlink-f() {
  local SOURCE="${1}"
  if [ -f "${SOURCE}" ] ; then
    local NAME="/$(basename "${SOURCE}")"
  else
    local SOURCE="$SOURCE/blah"
    local NAME=""
  fi
  while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
    local DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
    local SOURCE="$(readlink "$SOURCE")"
    # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
  done
  local RESULT="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  echo "${RESULT}${NAME}"
}
}

Wookrs fine for all except symlinked file, which is natureal due to dirname usage.. Morning would be better then evening. Thanx and see you tomorrow!

No I dont like that :D I will rather drop the usage in java/javac

@judovana judovana merged commit 23496c5 into rh-openjdk:master Apr 18, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants