Skip to content

Fix #11989: Remove dependency on find #12167

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

Merged
merged 3 commits into from
Apr 28, 2021
Merged

Conversation

liufengyun
Copy link
Contributor

Fix #11989: Remove dependency on find

@liufengyun
Copy link
Contributor Author

@michelou Do you have suggestions for removing the dependency on find?

@smarter
Copy link
Member

smarter commented Apr 26, 2021

We could emit jars without the version number in the filename so we can refer to them with a fixed identifier.

@michelou
Copy link
Contributor

@michelou Do you have suggestions for removing the dependency on find?

@liufengyun Let me start with two observations :

  1. I'm not aware of any rule/constraint about the organisation of the jar files inside the directory <scala_home>/lib/.
    NB. Using ls instead of find means that we assume a flat organisation of the jar files.
  2. As a hot reaction I would be inclined to say that a standard Unix distribution should include a command find.

So the point is to choose if we want to adapt the bash scripts to yet another user environment or we decide to introduce a requirement about the user environment.

Nevertheless I acknowledge the fact that people are working more and more with Docker images (which may provide very minimal sets of commands).

Side note : IMO it would worth looking at other JVM based tools (Java, Kotlin, etc.) regarding the jar file organisation.

Reminder :  ls only applies to the current working directory, while find applies to all files and subdirectories starting from the current working directory.

@liufengyun
Copy link
Contributor Author

Thanks @michelou.

I'm not aware of any rule/constraint about the organisation of the jar files inside the directory <scala_home>/lib/

Yes, the directory is flat, which is a safe assumption in our case.

ls seems to work fine on Mac, but Linux is not happy.

@griggt
Copy link
Contributor

griggt commented Apr 27, 2021

Another option may be something like this, which eliminates both the subshell and the dependency on an external command like find/ ls / etc.

find_lib () {
  for lib in "$PROG_HOME"/lib/$1 ; do
    if [[ -e "$lib" ]]; then
      if [ -n "$CYGPATHCMD" ]; then
        "$CYGPATHCMD" -am "$lib"
      elif [[ $mingw ||  $msys ]]; then
        echo "$lib" | sed 's|/|\\\\|g'
      else
        echo "$lib"
      fi
      return
    fi
  done
}

Co-authored-by: Tom Grigg <tomegrigg@gmail.com>
@liufengyun liufengyun marked this pull request as ready for review April 27, 2021 06:09
@liufengyun liufengyun requested a review from griggt April 27, 2021 06:11
@michelou
Copy link
Contributor

Another option may be something like this, which eliminates both the subshell and the dependency on an external command like find/ ls / etc.

find_lib () {
  for lib in "$PROG_HOME"/lib/$1 ; do
    if [[ -e "$lib" ]]; then
      if [ -n "$CYGPATHCMD" ]; then
        "$CYGPATHCMD" -am "$lib"
      elif [[ $mingw ||  $msys ]]; then
        echo "$lib" | sed 's|/|\\\\|g'
      else
        echo "$lib"
      fi
      return
    fi
  done
}

On line 137, [[ -e "$lib" ]] may also include subdirectories. Why do you not use option -f (regular files only) here ?

Copy link
Contributor

@griggt griggt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM.

@griggt griggt assigned liufengyun and unassigned griggt Apr 28, 2021
Co-authored-by: Stéphane Micheloud <stephane.micheloud@gmail.com>

Co-authored-by: Tom Grigg <tomegrigg@gmail.com>
@liufengyun liufengyun merged commit bb5e140 into scala:master Apr 28, 2021
@liufengyun liufengyun deleted the fix-11989 branch April 28, 2021 08:23
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.

find: command not found on openjdk-oraclelinux8
4 participants