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 | |
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 '')
-rw-r--r-- | info/gpp.texinfo | 12 | ||||
-rwxr-xr-x | src/gpp.py | 11 |
2 files changed, 19 insertions, 4 deletions
diff --git a/info/gpp.texinfo b/info/gpp.texinfo index 20049f4..133afc5 100644 --- a/info/gpp.texinfo +++ b/info/gpp.texinfo @@ -118,10 +118,20 @@ Number of iterations to run the preprocessing in. (Default: 1) @item -u @itemx --unshebang -Bland out the shebang line. Notice that the line is not removed, +Blank out the shebang line. Notice that the line is not removed, it is just cleared. You can use a shebang line make gpp preprocess the file when executed. +If @option{--unshebang} is used twice, the second line in the +file will be moved up to the top of the file and the initial +shebang line will be removed. A blank line will be inserted +after the new top line will be added to keep the line numbers +in the output file as near as possible to the line numbers +in the input file. The intension of this option is that you +can have two shebang lines, one on the first line for preprocessing +when the file is executed, and one shebang line on the second +line for output file. + @item -i @itemx --input Set the input file. (Default: /dev/stdin) @@ -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 |