1#!/bin/sh 2"""": # -*-python-*- 3# https://sourceware.org/bugzilla/show_bug.cgi?id=26034 4export "BUP_ARGV_0"="$0" 5arg_i=1 6for arg in "$@"; do 7 export "BUP_ARGV_${arg_i}"="$arg" 8 shift 9 arg_i=$((arg_i + 1)) 10done 11# Here to end of preamble replaced during install 12bup_python="$(dirname "$0")/../../config/bin/python" || exit $? 13exec "$bup_python" "$0" 14""" 15# end of bup preamble 16 17from __future__ import absolute_import, print_function 18import os.path, re, sys 19 20sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..'] 21 22from bup import compat, options, version 23from bup.io import byte_stream 24 25version_rx = re.compile(r'^[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9]+-g[0-9abcdef]+)?$') 26 27optspec = """ 28bup version [--date|--commit] 29-- 30date display the date this version of bup was created 31commit display the git commit id of this version of bup 32""" 33o = options.Options(optspec) 34opt, flags, extra = o.parse(compat.argv[1:]) 35 36 37total = (opt.date or 0) + (opt.commit or 0) 38if total > 1: 39 o.fatal('at most one option expected') 40 41sys.stdout.flush() 42out = byte_stream(sys.stdout) 43 44if opt.date: 45 out.write(version.date.split(b' ')[0] + b'\n') 46elif opt.commit: 47 out.write(version.commit + b'\n') 48else: 49 out.write(version.version + b'\n') 50