Results 1 to 2 of 2

Thread: mptopdf script in metapost broken

  1. #1

    Default mptopdf script in metapost broken

    In Tubleweed, the mptopdf perl script is broken. Whenever one runs mptopdf, it throws a tantrum and complains about -S not being an option known to the shell. So why is the shell executed rather than perl?

    The original script from CTAN starts with the usual perl invocation magic:
    Code:
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
            if 0;
    
    which works perfectly. But then someone added a #! line:
    Code:
    #! /bin/sh
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
            if 0;
    
    which does not work. This person did not read the manual page for perl, which states specifically that perl executes the shell it finds on the #!-line if it does not find the word "perl". So the magic code runs perl, perl parses the first line and sees "/bin/sh" and no mention of perl, and immediately runs /bin/sh with the same options it itself received.

    The perlrun(1) manual page also explains how to fix this: add a second #! line that contains the word perl. So the correct invocation would be:
    Code:
    #! /bin/sh
    #! -*-perl-*-
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
            if 0;
    
    This last version actually works. Note that the second line, although a comment, is essential! It cannot be left out...

    Someone please fix this, it's such a pain to have to fix the script each time the package is updated...

  2. #2
    Join Date
    Sep 2008
    Posts
    2,997

    Default Re: mptopdf script in metapost broken

    Quote Originally Posted by afm4711 View Post
    In Tubleweed, the mptopdf perl script is broken. Whenever one runs mptopdf, it throws a tantrum and complains about -S not being an option known to the shell. So why is the shell executed rather than perl?

    The original script from CTAN starts with the usual perl invocation magic:
    Code:
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
            if 0;
    
    which works perfectly. But then someone added a #! line:
    Code:
    #! /bin/sh
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
            if 0;
    
    which does not work. This person did not read the manual page for perl, which states specifically that perl executes the shell it finds on the #!-line if it does not find the word "perl". So the magic code runs perl, perl parses the first line and sees "/bin/sh" and no mention of perl, and immediately runs /bin/sh with the same options it itself received.

    The perlrun(1) manual page also explains how to fix this: add a second #! line that contains the word perl. So the correct invocation would be:
    Code:
    #! /bin/sh
    #! -*-perl-*-
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
            if 0;
    
    This last version actually works. Note that the second line, although a comment, is essential! It cannot be left out...

    Someone please fix this, it's such a pain to have to fix the script each time the package is updated...
    if you want that fixed report the above here
    https://bugzilla.opensuse.org/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •