aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-10-24 21:49:04 +0200
committerMattias Andrée <maandree@operamail.com>2013-10-24 21:49:04 +0200
commitf136aac49b09ab9746c236d2cce93d220800724f (patch)
treee9ebc085ab7f1af1126e1a8ef6dae2d3c8da61d8 /src
parentinfo manual: invoking (diff)
downloadgpp-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 '')
-rwxr-xr-xsrc/gpp.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gpp.py b/src/gpp.py
index 6881d98..5200b2a 100755
--- a/src/gpp.py
+++ b/src/gpp.py
@@ -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