0

I working on a version bump on the cc65 and encountered a problem with the linuxdoc-tools. Since I can't fix the linuxdoc-tools and there is a simple workaround possible I decided to add an if statement to inform the user together with the workaround:

    if {! [file exists ${prefix}/bin/perl] } {
        ui_error "
«${prefix}/bin/perl» is missing but the linuxdoc-tools depends on it.

Please create an appropriate symbolic link for linuxdoc-tools to work.
"
    exit 1
    }

Crude but the best I can do since I'm neither the perl5 nor the linuxdoc-tools maintainer and I don't want to spend to much time on a version bump.

However, the MacPorts doesn't understand exit 1 and ui_error won't stop execution on its own.

How do I stop the execution so not to waste the users time on a build which will otherwise fail right at the end.

Martin
  • 11,577
  • 16
  • 80
  • 110

1 Answers1

1

Use return -code error "error message", or the shorthand for the same thing, error "error message".

Note that you should use ui_error before that to print a human-readable message for the user – while the error message is also being printed, it can sometimes get lost in the output.

Additionally, note that $prefix/bin/perl is a build dependency of linuxdoc-tools. If it is also needed at runtime, you should submit a pull request that adds depends_run path:bin/perl:perl5 to the port rather than attempting to fix this bug in your port.

neverpanic
  • 2,918
  • 18
  • 27
  • Good point on `linuxdoc-tools` — the dependency in perl should be runtime instead of buildtime — however that Port is **nomaintainer**. So if I write a ticket then there is one who will fix that problem. – Martin Oct 05 '20 at 11:49
  • For such a simple change, submitting a pull request is usually the quickest way to get this resolved. However, in this particular case, Ryan was faster anyway and fixed it already: https://github.com/macports/macports-ports/commit/8946a11ddc2e36b46de594975914f743cd7bb3a8 – neverpanic Oct 06 '20 at 17:49