diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-10-24 21:49:04 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-10-24 21:49:04 +0200 |
commit | f136aac49b09ab9746c236d2cce93d220800724f (patch) | |
tree | e9ebc085ab7f1af1126e1a8ef6dae2d3c8da61d8 /src/gpp.py | |
parent | info manual: invoking (diff) | |
download | gpp-f136aac49b09ab9746c236d2cce93d220800724f.tar.gz gpp-f136aac49b09ab9746c236d2cce93d220800724f.tar.bz2 gpp-f136aac49b09ab9746c236d2cce93d220800724f.tar.xz |
add option: -u twice
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/gpp.py')
-rwxr-xr-x | src/gpp.py | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -29,7 +29,7 @@ encoding = 'utf-8' iterations = 1 input_file = '/dev/stdin' output_file = '/dev/stdout' -unshebang = False +unshebang = 0 args = sys.argv @@ -46,7 +46,7 @@ for i in range(1, len(args)): if arg in ('-s', '--symbol'): symbol = sys.argv[i] elif arg in ('-e', '--encoding'): encoding = sys.argv[i] elif arg in ('-n', '--iterations'): iterations = int(sys.argv[i]) - elif arg in ('-u', '--unshebang'): unshebang = True; continue + elif arg in ('-u', '--unshebang'): unshebang += 1; continue elif arg in ('-i', '--input'): input_file = sys.argv[i] elif arg in ('-o', '--output'): output_file = sys.argv[i] elif arg in ('-f', '--file'): @@ -100,10 +100,15 @@ data = None with open(input_file, 'rb') as file: data = file.read().decode(encoding, 'error').split('\n') -if unshebang: +if unshebang == 1: if data[0][:2] == '#!': data[0] = '' +if unshebang >= 2: + if data[0][:2] == '#!': + data[0] = data[1] + data[1] = '' + def pp(line): rc = '' symb = False |