annotate unixSoft/bin/patchpipe @ 377:117e3c11d953

zprofile: introduce zprofile use El Capitan (OS X 10.11) introduces a system-level /etc/zprofile which uses a path_helper thing to mangle $PATH. Unfortunately, the way path_helper works, it forces /usr/local/bin and /usr/bin to the *start* of the PATH variable, which means that any PATH mutations I want have to run after /etc/zprofile calls path_helper. As such, move my path insertions into .zprofile{,-machine} rather than .zshenv{,-machine} so that I can still ensure my path entries are at the start of PATH rather than the end. This works because: > Commands are then read from $ZDOTDIR/.zshenv. If the shell is a > login shell, commands are read from /etc/zprofile and then > $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands > are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the > shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read. This means that non-login shells no longer pick up my custom PATH entries, but as I only use OS X as a desktop OS that seems like a workable tradeoff for now.
author Augie Fackler <raf@durin42.com>
date Sun, 31 Jan 2016 20:46:29 -0500
parents c7a9cd793e37
children a5a4f9e12c9f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
344
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
1 #!/usr/bin/env python
357
c7a9cd793e37 patchpipe: handle base64-encoded message bodies
Augie Fackler <raf@durin42.com>
parents: 344
diff changeset
2 import base64
344
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
3 import os
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
4 import subprocess
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
5 import sys
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
6 import tempfile
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
7
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
8 _PATCHHDR = '# HG changeset patch'
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
9
357
c7a9cd793e37 patchpipe: handle base64-encoded message bodies
Augie Fackler <raf@durin42.com>
parents: 344
diff changeset
10 _BASE64_MAGIC = 'Content-Transfer-Encoding: base64'
c7a9cd793e37 patchpipe: handle base64-encoded message bodies
Augie Fackler <raf@durin42.com>
parents: 344
diff changeset
11
344
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
12
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
13 def main(argv):
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
14 tf = tempfile.NamedTemporaryFile(suffix='.diff')
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
15 d = sys.stdin.read()
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
16 if _PATCHHDR in d:
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
17 junk, d = d.split(_PATCHHDR, 1)
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
18 d = _PATCHHDR + d
357
c7a9cd793e37 patchpipe: handle base64-encoded message bodies
Augie Fackler <raf@durin42.com>
parents: 344
diff changeset
19 elif _BASE64_MAGIC in d:
c7a9cd793e37 patchpipe: handle base64-encoded message bodies
Augie Fackler <raf@durin42.com>
parents: 344
diff changeset
20 junk, d = d.split('\n\n', 1)
c7a9cd793e37 patchpipe: handle base64-encoded message bodies
Augie Fackler <raf@durin42.com>
parents: 344
diff changeset
21 d = d.decode('base64')
344
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
22 tf.write(d)
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
23 tf.flush()
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
24 subprocess.check_call([os.environ['EDITOR'], tf.name],
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
25 stdout=sys.stderr)
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
26 sys.stdout.write(open(tf.name).read())
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
27
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
28
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
29 if __name__ == '__main__':
4e83916a4303 patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff changeset
30 main(argv=sys.argv)