about summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive/patch-scripts.sed
blob: c08d765ebd717825e607656631bf16f76f32d145 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
1{
  /python/{
    N;
    # add script folder to path, unless we interfere with a docstring
    /\nr"""/b skip-python-path-patch
    s!\n!\nimport sys; sys.path.insert(0,'@scriptsFolder@')\n!
    :skip-python-path-patch
  }

  /^#!.*perl/{
    # add script folder to @INC
    s!$! -I@scriptsFolder@!
  }

  /^eval/{
    # most likely the weird perl shebang
    N
    /^eval '(exit \$?0)' && eval 'exec perl -S \$0 \${1+"\$@"}' && eval 'exec perl -S \$0 \$argv:q'\n *if 0;$/{
      x; s/.*/patching weird perl shebang/; w /dev/stderr
      x; s|^.*$|#!@interpPerl@ -I@scriptsFolder@|
    }
  }
}

# patch 'exec interpreter'
/exec java /{
  x; s/.*/patching exec java/; w /dev/stderr
  x; s|exec java |exec '@interpJava@' |g
  /exec ''/{
    x; s/^.*$/error: java missing from PATH/; w /dev/stderr
    q 1
  }
}

/exec perl /{
  x; s/.*/patching exec perl/; w /dev/stderr
  x; s|exec perl |exec @interpPerl@ -I@scriptsFolder@ |g
  /exec ''/{
    x; s/^.*$/error: perl missing from PATH/; w /dev/stderr
    q 1
  }
}

/exec wish /{
  x; s/.*/patching exec wish/; w /dev/stderr
  x; s|exec wish |exec '@interpWish@' |g
  /exec ''/{
    x; s/^.*$/error: wish missing from PATH/; w /dev/stderr
    q 1
  }
}

# make jar wrappers work without kpsewhich
s!^jarpath=`kpsewhich --progname=[^ ]* --format=texmfscripts \([^ ]*\)`$!jarpath=@scriptsFolder@/\1!g

# replace CYGWIN grep test with bash builtin
s!echo "$kernel" | grep CYGWIN >/dev/null;![[ "$kernel" == *CYGWIN* ]]!g