#4 Prevent deleting dirs/files out of the java folders
Merged by jvanek. Opened by jvanek.
jvanek/copy_jdk_configs doNotEscape  into  master

https://bugzilla.redhat.com/show_bug.cgi?id=2100617

rebased onto 8f8401e6c61877ae66e836670f5ada401a18f2d4

rebased onto 84f4a063a001e163f4b7ffeada22db3696503e97

It looks like -delete should also have been removed from this find command.

dman overlook. TY!

rebased onto 78cbbfd228957f28c2d6fdc2c7daf10a111329e8

that one line force pushed

I'm a bit concerned about how readlink -f $arg` = /etc/java/java* expands. Would the * not be interpreted as a pattern matching character and /etc/java/java* replaced with whatever files the user has that match the pattern?

$ echo `readlink -f /usr/lib/jvm/java-17-openjdk/conf` = /etc/java/java*
/etc/java/java-17-openjdk/java-17-openjdk-17.0.4.0.8-2.el8_6.x86_64/conf = /etc/java/java-11-openjdk /etc/java/java-17-openjdk /etc/java/java-1.8.0-openjdk /etc/java/java-18-openjdk /etc/java/java.conf

See https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html

It would seem grep would be a better choice here.

$ if readlink -f /usr/lib/jvm/java-17-openjdk/conf| egrep -q '^(/etc/java|/usr/lib/jvm)' ; then echo "Correct JDK folder"; else echo "Incorrect"; fi
Correct JDK folder
$ if readlink -f /usr/lib| egrep -q '^(/etc/java|/usr/lib/jvm)' ; then echo "Correct JDK folder"; else echo "Incorrect"; fi
Incorrect

How are you testing this change?

I'm a bit concerned about how `readlink -f $arg` = /etc/java/java* expands. Would the * not be interpreted as a pattern matching character and /etc/java/java* replaced with whatever files the user has that match the pattern?
[...]
See https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
[...]

Hi Andrew, I don't dislike the grep-based solution, but let me point out that in this case, according to the Conditional Constructs documentation for [[ expression ]]:

[...]
Word splitting and filename expansion are not performed on the words between the [[ and ]]; tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal are performed.
[...]

So filename expansion shouldn't be applied. From another paragraph below, it seems that pattern matching is applied instead:

[...]
When the ‘==’ and ‘!=’ operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below in Pattern Matching, as if the extglob shell option were enabled.
[...]

Ok, I wasn't aware that [[ had different behaviour, I was assuming it worked like test or [. While it makes the code less clear, I'm ok with this going in. I would suggest caching the results of readlink and realpath though, which should also increase the legibility of that bit of script.

I would suggest caching the results of readlink and realpath though, which should also increase the legibility of that bit of script.

Totally agree

tyvm. Will fix

As for the how do you test the chnage, is a bot issue. I was able to leak out of java space, and this seems to be fixing it, but I do nto have exact reproducer from the case. I will speed this now to rhel, it have ot end in october CPu

1 new commit added

  • Extracted realpath and readlin to variables

ello! Done. Xan you please seal the verdict?

Pull-Request has been merged by jvanek

Metadata