Skip to content

bash script "common" find_lib() function needs to handle missing libraries #6727

Closed
@philwalk

Description

@philwalk

After installing dotty 0.16 and calling 'dotr' from a cygwin bash shell environment, error messages are printed. Here are the first few lines of the error message, but to see the whole thing, just type 'cygpath' with no arguments.

Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME...
       cygpath [-c HANDLE]
       cygpath [-ADHOPSW]
       cygpath [-F ID]

Here is the relevant script section, centered near line 100 of bash script dotty/bin/common:

minimized code

find_lib () {
  local lib=$(find $PROG_HOME/lib/ -name "$1")
  if $cygwin; then
    cygpath -am $lib
  elif $mingw; then
    echo $lib | sed 's|/|\\\\|g'
  else
    echo $lib
  fi
}

Because the "scala-xml" library is not distributed with dotty 0.16, 41 lines of error message are printed, due to cygpath being called with no file path argument.

The following is the call that triggers an error message, either because scala-xml jar file is missing, or because find_lib() need to avoid calling cygpath when the library is missing:

SCALA_XML=$(find_lib "*scala-xml*")

expectation

No error messages.

Adding 2 lines to test 'lib' for the empty string would seem to be a general fix:

find_lib () {
  local lib=$(find $PROG_HOME/lib/ -name "$1")
  if [ -z "$lib" ]; then
    echo
  elif $cygwin; then
    cygpath -am $lib
  elif $mingw; then
    echo $lib | sed 's|/|\\\\|g'
  else
    echo $lib
  fi
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions