chiark / gitweb /
script: Break out treat_as_pinned
[otter.git] / run-inkscape-extension
1 #!/bin/bash
2 #
3 # inkscape 0.92.4 on Debian buster:
4 # These scripts are perfectly good scripts; they are executable,
5 # and they work with the #! that is provided.  They do not work with
6 # python2.
7 #
8 # inkscape 1.0.2 on Debian bullseye:
9 # These files are not executable.  They say #!/usr/bin/env python
10 # but the system probably doesn't have any such thing, because
11 # that would (on a sane system) refer to python2 and there is
12 # only python3.
13 #
14 # I don't think it is going to be possible to sanely find out what
15 # python version is actually expected.  But I think a *reasonable*
16 # demand on the environment is that either:
17 #   - If these scripts are executable, they can be executed
18 #   - Otherwise, they are not using ancient and obsolete python
19
20 set -e
21
22 $(
23   if test -x "$1"; then :; else
24     type -p python3 || type -p python
25   fi
26 ) "$@"
27
28 # Additionally, sometimes inkscape doesn't write the output file.  It
29 # likes to do this if "nothing changed", presumably because of some
30 # "don't save non-dirty files" logic.  That is really nto very
31 # convenient here!
32
33 if test -f /dev/stdout; then
34   if test -s /dev/stdout; then :; else
35     x=("$@");
36     cat ${x[-1]}
37   fi
38 fi